6

I am building an Android app for RAM optimization. I can successfully get the list of running processes (and their PIDs) using this answer. However, I don't see a way to kill them or their background services by PID.

2

1 Answer 1

11

It turned out to be something very basic:

ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);

for (RunningAppProcessInfo pid : am.getRunningAppProcesses()) {
    am.killBackgroundProcesses(pid.processName);
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.