With PackageManager you can access all the installed packages and you can request system to kill the background process by ActivityManager. Here is a working code snippet.
List<ApplicationInfo> packages;
PackageManager pm;
pm = getPackageManager();
packages = pm.getInstalledApplications(0); //get a list of installed apps.
ActivityManager mActivityManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
for (ApplicationInfo packageInfo : packages) {
if((packageInfo.flags & ApplicationInfo.FLAG_SYSTEM)==1) continue; // Exclude system packages
if(packageInfo.packageName.equals("mypackage")) continue; // Exclude your packages/application
mActivityManager.killBackgroundProcesses(packageInfo.packageName);
}
Update:
These permissions must be requested,
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<uses-permission android:name="android.permission.GET_TASKS" />
Hope this helps!