问题
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