How to kill another user's background process?

允我心安 提交于 2019-12-22 17:53:29

问题


I'm not able to kill another user's background process using ActivityManager.killBackgroundProcesses.

Code used is:

 ActivityManager am = (ActivityManager)getSystemService(ACTIVITY_SERVICE);

 for (RunningAppProcessInfo pid : am.getRunningAppProcesses())
 {
     if (pid.processName.equals("com.example.sample"))
        am.killBackgroundProcesses("com.example.sample");
 }

Where com.example.sample is the package of the background process which I want to delete.

That process is still running in the background after this completes.


回答1:


You can only kill your own apps, e.g. the ones running in the same process or with the same userID. You can not kill others, unless the device is rooted.

Have a look at this answer though, about 'killing' background processes of apps.



来源:https://stackoverflow.com/questions/25508470/how-to-kill-another-users-background-process

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