My app starts others apps (upon user request) using this simple code:
Intent LaunchApp = getPackageManager().getLaunchIntentForPackage("the.external.app.package");
startActivity( LaunchApp );
Is there a way to finish or close that app?
I have tried with ActivityManager.killBackgroundProcesses() and with android.os.Process.sendSignal(pid, android.os.Process.SIGNAL_KILL) but no success.
The idea is to do something like this: If the app connects to the car bluetooth then it starts the music player automatically. Once the bluetooth is disconnected it should close the music player.
Thanks
You can close activity without killing process.
Use startActivityForResult()
instead startActivity()
startActivityForResult( LaunchApp, 100 );// reques code = 100
Close activity by request code when you need that
finishActivity( 100 );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.