How to get running process in Android?

Viewed 1447

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

1 Answers
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

Related