/**********************************************************************
* Android Kill Process
* 说明:
* 在Android App中杀死其他的App进程。
*
* 2017-8-5 深圳 龙华樟坑村 曾剑锋
*********************************************************************/
一、参考文档:
. Why KILL_BACKGROUND_PROCESSES doesn't work? [closed]
https://*.com/questions/15030863/why-kill-background-processes-doesnt-work
二、处理代码:
...
ActivityManager manager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
try {
manager.killBackgroundProcesses("com.example.xxx");
} catch (Exception ex) {
Log.e(TAG, ex.toString());
}
...
三、错误现象:
W/ActivityManager( ): Permission Denial: killBackgroundProcesses() from pid=, uid= requires android.permission.KILL_BACKGROUND_PROCESSES
E/AplexOS (): java.lang.SecurityException: Permission Denial: killBackgroundProcesses() from pid=, uid= requires android.permission.KILL_BACKGROUND_PROCESSES
四、解决办法:
添加权限:<user-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />