there is an easier way. You can get the list of running processes with the method
Code:
public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses ()
from ActivityManager class
and to stop an app there is
Code:
public void restartPackage (String packageName)
Have the system perform a force stop of everything associated with the given application package. All processes that share its uid will be killed, all services it has running stopped, all activities removed, etc. In addition, a ACTION_PACKAGE_RESTARTED broadcast will be sent, so that any of its registered alarms can be stopped, notifications removed, etc.
You must hold the permission RESTART_PACKAGES to be able to call this method.
I believe these are the methods used by task killer and other apps of that kind.
APNdroid does help extending battery life but the problem is it cuts all data connectivity and you won't have email on your phone. A device without email can hardly be called a "smartphone".
I think I found what was keeping my device awake although the screen was off (I had like 99% of the time the device running and only 10% the screen on), it was the damn case, it's too tight and some buttons were being pressed when I had the device in my pocket. Now without using it I have the device running for almost 48 hours and my battery is at 26%, with 3G on for most of the time, background data active, gmail sync.