How do Task Managers kill apps? How do Task Managers kill apps? android android

How do Task Managers kill apps?


You can send the signal using:

Process.sendSignal(pid, Process.SIGNAL_KILL);

To completely kill the process, it's recommended to call:

ActivityManager.killBackgroundProcesses(PackageName)

before sending the signal.


slayton has good answer in this question.I add this detail to his answer:
- when you use ActivityManager.killBackgroundProcesses(PackageName) , you can not kill foreground process.

I saw these open sources project link in K_Anas'answer to this question:
- github repository
- code.google


try this,

android.os.Process.killProcess(pid)

that will work...