Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid task killer
    primarykey
    data
    text
    <p>Im trying to write a simple task killer. I know I shouldnt kill tasks in Android, but Im eager to try something like this. I have the following code:</p> <pre><code>List&lt;RunningAppProcessInfo&gt; procInfo = activityManager.getRunningAppProcesses(); for (int i = 0; i &lt; procInfo.size(); i++) { Log.v("proces " + i,procInfo.get(i).processName + " pid:" + procInfo.get(i).pid + " importance: " + procInfo.get(i).importance + " reason: " + procInfo.get(i).importanceReasonCode); //First I display all processes into the log } for (int i = 0; i &lt; procInfo.size(); i++) { RunningAppProcessInfo process = procInfo.get(i); int importance = process.importance; int pid = process.pid; String name = process.processName; if (name.equals("manager.main")) { //I dont want to kill this application continue; } if (importance == RunningAppProcessInfo.IMPORTANCE_SERVICE) { //From what I have read about importances at android developers, I asume that I can safely kill everithing except for services, am I right? Log.v("manager","task " + name + " pid: " + pid + " has importance: " + importance + " WILL NOT KILL"); continue; } Log.v("manager","task " + name + " pid: " + pid + " has importance: " + importance + " WILL KILL"); android.os.Process.killProcess(procInfo.get(i).pid); } procInfo = activityManager.getRunningAppProcesses(); //I get a new list with running tasks for (int i = 0; i &lt; procInfo.size(); i++) { Log.v("proces after killings" + i,procInfo.get(i).processName + " pid:" + procInfo.get(i).pid + " importance: " + procInfo.get(i).importance + " reason: " + procInfo.get(i).importanceReasonCode); } </code></pre> <p>My problem here is that when I perform this code, I first get the list of all tasks, thats ok. Than I see in the log several lines of:</p> <pre><code>Sending signal. pid: (processId) SIG: 9 </code></pre> <p>I asume thats a signal to die. But at the end of my code, when I display all running processes, the list is the same as before, no task has been killed. Any ide why? Thank you!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload