[英]Get Running Processes List and Kill Their Background Services
I am building an Android app for RAM optimization. 我正在构建一个用于RAM优化的Android应用程序。 I can successfully get the list of running processes (and their PIDs) using this answer .
我可以使用这个答案成功获取正在运行的进程列表(及其PID)。 However, I don't see a way to kill them or their background services by PID.
但是,我没有看到通过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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.