1

I have an unrooted Android 2.3.4 device and am using an app (not my app) that sometimes starts to go nuts and uses 100% cpu power for no reason (its a bug) which drains the battery power really quickly and is also considerably slowing the device down. I can use a taskkiller to end it but thats not really an option so I made an app that monitors that other app and tries to end it whenever it detects too crazy cpu usage.

The problem I face now is how to end that app. I tried the following 4 methods but unfortunately to no avail:

ActivityManager actvityManager = (ActivityManager) getSystemService( ACTIVITY_SERVICE );
actvityManager.killBackgroundProcesses(packagename);

android.os.Process.sendSignal(pid, android.os.Process.SIGNAL_KILL);

android.os.Process.killProcess(pid);

actvityManager.restartPackage(packagename);

I can use a regular taskkilling tool to end it (it really does, I verified that), but I would like to do that programmatically myself and not with other means (and by that I also mean rebooting and not using the app).

How can I end such a process?

PS: I know that the termination of processes should under normal circumstances be left to Android but that is obviously not sufficient in this case, so I need to handle it myself.

HardCoder
  • 3,026
  • 6
  • 32
  • 52
  • Do you have the permission set to kill background processes in your manifest? And how are you making sure that the process is actually locking the system? I hope you're not just checking to see if CPU use goes above a certain limit and killing it. – dymmeh Apr 19 '12 at 21:22
  • Yes, I set the permissions 'android:name="android.permission.KILL_BACKGROUND_PROCESSES'"> and 'android.permission.REORDER_TASKS'. And I check the cpu usage in 8 second intervalls over 32 seconds (testing that value currently) and when it is for the entire time over 75% (and a few other parameters) I know its buggy again. – HardCoder Apr 19 '12 at 21:31
  • My suggestion: Remove the app and find an alternative. Then send a bug report to the dev. – Kevin Coppock Apr 19 '12 at 21:41
  • Unfortunately that is not an option because I cannot uninstall it (it came with the device and it is and will remain unrooted) and it is actually a really good app that I also want to continue to use. Otherwise I would not go to these lengths in the first place. – HardCoder Apr 19 '12 at 21:49

0 Answers0