Android-Close Other Apps
- by Luke
I have some code that will launch a different application using intents but what can I do to close or kill the other app?
Here is the launch code (works great):
Intent i = new Intent();
i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setComponent(
new ComponentName(resolveInfo.activityInfo.applicationInfo.packageName,
resolveInfo.activityInfo.name));
I tried to kill the background processes but no luck:
ActivityManager activityManager = (ActivityManager) context.getSystemService(context.ACTIVITY_SERVICE);
activityManager.killBackgroundProcesses("com.pandora.android");
I also tried this to kill it:
context.stopService(new Intent(context, Class.forName("com.bla.bla")));