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)