zoukankan      html  css  js  c++  java
  • Android Kill Process

    /**********************************************************************
     *                   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" />
  • 相关阅读:
    HDU 1261 字串数(排列组合)
    Codeforces 488C Fight the Monster
    HDU 1237 简单计算器
    POJ 2240 Arbitrage
    POJ 3660 Cow Contest
    POJ 1052 MPI Maelstrom
    POJ 3259 Wormholes
    POJ 3268 Silver Cow Party
    Codesforces 485D Maximum Value
    POJ 2253 Frogger(最短路)
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/7290463.html
Copyright © 2011-2022 走看看