2013-02-21

Android API to kill background processes



ActivityManager am = (ActivityManager) mContext.getSystemService(Activity.ACTIVITY_SERVICE);
List<RunningTaskInfo> tasks =am.getRunningTasks(Integer.MAX_VALUE);
for(int i=0;i<tasks.size();i++)
{
String packageName = tasks.get(i).baseActivity.getPackageName();
am.killBackgroundProcesses(packageName);
}
Please refer to http://developer.android.com/reference/android/app/ActivityManager.html#killBackgroundProcesses(java.lang.String)

Also you can kill running apps, services by using API: getRunningAppProcesses(), getRunningServices()

No comments: