How to kill another user's background process?

2019-05-19 23:15发布

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条回答
一夜七次
2楼-- · 2019-05-19 23:46

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.

查看更多
登录 后发表回答