1

I am writing an app that intercepts the launching of apps, killing them, then restarting them if certain permissions are met. I've managed to figure out the first part(launching of apps) by having a service that monitors the system log. I'm now working on killing the app that was just launched. I'm trying to use:

ActivityManager.killBackgroundProcesses(packageName);

but I'm not sure if this will kill the entire app, including all services/tasks that it starts. I've tried using killBackgroundProcesses() to indiscriminately kill all apps that are launching, but the app still seems to start.

I've also tried android.os.Process.killProcess(pid), passing the other app's pid, however the app still seems to start as well.

user1118764
  • 9,255
  • 18
  • 61
  • 113

1 Answers1

1

Every Activity has its own processID, while service dont have its own id or something, service is a part of Activity. when you killing activity process its will stop all the partial task or service too

refer http://developer.android.com/resources/faq/framework.html

Mohammed Azharuddin Shaikh
  • 41,633
  • 14
  • 96
  • 115
  • Thanks. So if I kill the process, it will stop all parts of the app from running and remove it from memory? How can I kill a process from another app though? I tried android.os.Process.killProcess(pid) but that didn't work. When I tried "kill pid" from adb shell it worked though. – user1118764 Dec 28 '11 at 06:58
  • So it seems like there's no way at all for one service to kill another process/app? – user1118764 Dec 28 '11 at 07:22
  • So instead of killing the app A, I just tried to throw an intent to another activity B, hoping that it will halt execution of the original app A. It seems to work, as I tried a very simple app A that writes a line to the log in its onCreate(), and the line isn't written until I get out of the activity B. I guess this is the best I can do. – user1118764 Dec 29 '11 at 01:58