I am developing an application which can launch number of other applications. I can successfully launch new applications from my app. The problem is when the launched application crashes, my application is taken back to the previous screen(From the screen where new app is launched).How can i make sure my app stays in the same screen even if the newly launched app crashes.I tried to set the intent flag Intent.FLAG_ACTIVITY_NEW_TASK while launching new app but this didnt work.
Intent LauncherIntent = getActivity().getPackageManager().getLaunchIntentForPackage(package.trim());
if(LauncherIntent != null){
LauncherIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getActivity().startActivity(LauncherIntent);
}
This code snippet is used to launch the new app.The ‘package’ will have the package info of newly launched app.
Try this: