android task kill

后端 未结 5 592
我寻月下人不归
我寻月下人不归 2020-12-11 03:48

I want to kill all tasks that run in android like task killer... What I have done until now is:

ActivityManager manager =  (ActivityManager) this.getSystemSe         


        
5条回答
  •  醉话见心
    2020-12-11 04:04

    You're using 0 (zero) instead of i inside your loop.

    for (int i = 0; i < activityes.size(); i++){
    
        Log.e("APP: "+i, activityes.get(i).processName);
    
        if (!activityes.get(i).processName.equals("app.android.myapp")){
            Process.killProcess(activityes.get(i).pid);
        }
    
    }
    

    Cheers

提交回复
热议问题