Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android task kill

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

ActivityManager manager =  (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
    List<RunningAppProcessInfo> activityes = ((ActivityManager) manager).getRunningAppProcesses();

    for (int i = 0; i < activityes.size(); i++){

        Log.e("APP: "+i, activityes.get(0).processName);

        if (!activityes.get(0).processName.equals("app.android.myapp")){
            Process.killProcess(activityes.get(0).pid);
        }

    }

The problem with the code is that it returns in the activityes list only my app for 12 times. And no task is being killed...

Can somebody help me please? Thank you!

like image 738
Cata Avatar asked Feb 07 '11 12:02

Cata


People also ask

Are task killers good for Android?

In reality, task killers can reduce your performance and battery life. Task killers can force apps running in the background to quit, removing them from memory. Some task killers do this automatically. However, Android can intelligently manage processes on its own – it doesn't need a task killer.

What is Task kill?

Ends one or more tasks or processes. Processes can be ended by process ID or image name. You can use the tasklist command command to determine the process ID (PID) for the process to be ended. Note. This command replaces the kill tool.

How do I find app kills on Android?

for User kill( use App switcher ): counter activity number/taskstack etc. (unspecify)for Android Framework kill(Low Memory etc): (unspecify)for Native kill(Process. kill kill signal): use native.

Is it OK to force stop an app?

Force stopping an app usually solves the problem if the app is misbehaving. But you might want to reconsider before you press that button. If you're doing something important, you will likely lose your unsaved data in the app.


1 Answers

You do not have the rights to kill other processes; hence, killProcess() does not work for your app.

like image 155
CommonsWare Avatar answered Sep 27 '22 18:09

CommonsWare