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.
Asked
Active
Viewed 1.4k times
6
-
1Try here: http://stackoverflow.com/questions/2720164/android-process-killer – Tamir Scherzer Oct 15 '12 at 09:15
-
1Duplicate of http://stackoverflow.com/q/9804786/1321873 – Rajesh Oct 15 '12 at 09:17
1 Answers
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);
}

Dzhuneyt
- 8,437
- 14
- 64
- 118