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")));
I want to kill other applications because I launch other applications and users have requested this additional feature (auto kill is a natural extension of auto launch). Please answer the question of how to accomplish this in code. I know about Advanced Task Mgr so it is possible but how?
I ended up finding the real answer to this question. Please see Automate closing of applications in Android for the solution!
but what can I do to close or kill the other app?
You don't. Your user can exit that "other app" when they wish to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With