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.