Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Check application process State

How can I check the state (pause/running/suspended) of a particular process running on the Android device programmatically? I want to include this logic within my application.

Using ActivityManager, I am able to retrieve a list of all processes running on the device, but it doesn't show me any process state information. Any idea on how I can retrieve this information?

Thanks in Advance.

like image 937
NavinC Avatar asked Dec 09 '25 13:12

NavinC


1 Answers

I was wrong when I mentioned in the question that there is no process state information in the list of processes retrived using ActivityManager.

 ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
   List<RunningAppProcessInfo> list2= am.getRunningAppProcesses();
   for (RunningAppProcessInfo ti : list2) {

       Log.i("IMPORTANCE CODE",String.valueOf(ti.importance));
  }

ti.importance retrives a constant value which describes whether the process is running FOREGROUND, BACKGROUND, Empty of code etc...

More information can be found at the following location:

http://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo.html

Thanks, Navin

like image 135
NavinC Avatar answered Dec 12 '25 04:12

NavinC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!