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.
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);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.