Get Running Processes List and Kill Their Background Services

时光毁灭记忆、已成空白 提交于 2019-11-30 07:01:19

问题


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.


回答1:


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);
}


来源:https://stackoverflow.com/questions/12892400/get-running-processes-list-and-kill-their-background-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!