I want to close another app opened from my app with an intent.
On my app, I create an intent to open Google Maps, but I want to close this Google Maps with a button on my app.
Is that possible?
It is not possible to close the another app from your app.
It is ethically not correct and there is no official Android API as well.
You can only close the background processes of other apps, you are no longer able to close their main activities.
Declare a permission for that in your AndroidManifest file:
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
In your app:
ActivityManager manager = (ActivityManager)getSystemService(Activity.ACTIVITY_SERVICE);
manager.killBackgroundProcesses(packageName);
I have used this code and it has worked for me.
Hope this can help you, thanks.
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