Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • App is in running state or not

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 662
    Comment on it

    App is in running state or not:

    We can know the status (Running or not) of our application by using ActivityManager class and attribute ACTIVITY_SERVICE.
    We just check our process name to compare with package name of the project.

    ActivityManager activityManager = (ActivityManager) this.getSystemService( ACTIVITY_SERVICE );
                List procInfos = activityManager.getRunningAppProcesses();
                for(int i = 0; i < procInfos.size(); i++){
                    ServerUrl.sendLog("Size::::::::::::; "+procInfos.size());
                    ServerUrl.sendLog("Process name :: "+procInfos.get(i).processName);
                    if(procInfos.get(i).processName.equals("com.medvisitpatients.patient"))
                    {
                        //Do whatever we want
                        break;
                    }
                    else
                    {
                        Log.e("Result", "App is not running - Needs to reload");
                    }
                }

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: