/********************************************************************** * Android Kill Process * 说明: * 在Android App中杀死其他的App进程。 * * 2017-8-5 深圳 龙华樟坑村 曾剑锋 *********************************************************************/ 一、参考文档: 1. Why KILL_BACKGROUND_PROCESSES doesn‘t work? [closed] https://stackoverflow.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( 506): Permission Denial: killBackgroundProcesses() from pid=11476, uid=10043 requires android.permission.KILL_BACKGROUND_PROCESSES E/AplexOS (11476): java.lang.SecurityException: Permission Denial: killBackgroundProcesses() from pid=11476, uid=10043 requires android.permission.KILL_BACKGROUND_PROCESSES 四、解决办法: 添加权限:<user-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
时间: 2024-10-03 09:10:30