Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在构建一个用于 RAM 优化的 Android 应用程序。我可以使用此答案成功获取正在运行的进程(及其 PID)列表。但是,我看不到通过 PID 杀死它们或它们的后台服务的方法。
事实证明这是非常基本的:
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (RunningAppProcessInfo pid : am.getRunningAppProcesses()) { am.killBackgroundProcesses(pid.processName); }