As of API level 21, getRunningAppProcesses() returns the app itself. How can I get the processes running in the android ?
Asked
Active
Viewed 1,505 times
1 Answers
0
private boolean isMyServiceRunning(Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (serviceClass.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
Pass the class that you need to check

lcukerd
- 83
- 1
- 10
-
No I don't need the service running app. Even if the app is destroyed the service will be running and your code will only provide that. – Mayank Raj Sep 24 '17 at 18:44
-
1You want to get list of all service running from all apps on phone? – lcukerd Sep 24 '17 at 18:46
-
No I want to get all the apps running in background. – Mayank Raj Sep 24 '17 at 18:51
-
Well, activity can't run in the background, only service can. So if an app is running in the background then it is that app's service running. – lcukerd Sep 24 '17 at 18:55
-
You didn't get me. What I mean by background is that the app isn't destroyed it's in onPause phase. – Mayank Raj Sep 24 '17 at 19:03
-
Sorry, but I don't think it's possible. If it is then I don't know. – lcukerd Sep 24 '17 at 19:26