3

As of API level 21, getRunningAppProcesses() returns the app itself. How can I get the processes running in the android ?

Mayank Raj
  • 921
  • 2
  • 12
  • 23

1 Answers1

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