Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android process killer

Maybe you can help.

Is it possible to get list of all Processes which are running in the Android system, and kill some of them? I know that there are some applications (task managers), but I would like to write my own, simple application.

I would like to write simple task manager, just list of all processes and button which will kill some of them.

Could you just write some Java methods which I can call in order to get list of process, and method for killing them. Or just give me some advice's.

like image 255
Martin Avatar asked Apr 27 '10 09:04

Martin


1 Answers

Killing apps/services in Android is generally a really bad idea. Whilst it is possible to write task killer apps, it shouldn't be encouraged for anything outside of development/debugging purposes.

Task management is the responsibility of the Android O/S, the tasks you can see are not processes (in the sense of the processes you see in the Windows task manager for example), in fact, they only have a process when Android tells them they can have one.

Apps are regularly broken by these task management tools, as they often fail to recover from the forced termination, particularly if they were busy writing to a file or using another resource when they were killed. It also puts the handset users into a false expectation that the apps listed are actually RUNNING on their phone, which they are often not. This is explained in the [ActivityManager docs][1]:

Information you can retrieve about a particular task that is currently "running" in the system. Note that a running task does not mean the given task actual has a process it is actively running in; it simply means that the user has gone to it and never closed it, but currently the system may have killed its process and is only holding on to its last state in order to restart it when the user returns.

When you see the list of running apps in apps like TaskKiller or Quick System Info, many of them are not actually running, they are just in a suspended state. These apps are not consuming system resources because Android has decided to stop them until they are needed again. However, when you kill them, you don't give them time to shut down cleanly, and when you try to launch them next time you can be presented with an unfriendly force close dialog. I have seen apps break completely, with even a re-install being ineffective, because they are trying to read a corrupted file on the SD card, or they use unofficial API calls.

In short, friends don't let friends use task killers in Android.

Anyway, to answer your question, the ActivityManageris what most of these apps use to list activities that are in running/suspended state.

freetaskmanager is an example of one of these task managers in use.

like image 100
seanhodges Avatar answered Sep 16 '22 20:09

seanhodges