私のアプリケーションでは、次のようにデバイスで他のアプリを起動します。
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(packageName);
if (LaunchIntent == null) return;
LaunchIntent.addCategory(Intent.CATEGORY_LAUNCHER);
LaunchIntent.setAction(Intent.ACTION_MAIN);
LaunchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
startActivity(LaunchIntent);
そして、実行されたアプリがクラッシュするまで、すべて正常に動作します。この場合、私のアプリも強制終了します。
01-06 20:13:00.796 4560-4560/com.example.android.trivialdrivesample E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.trivialdrivesample/com.example.android.trivialdrivesample.MainActivity}: java.lang.RuntimeException: Please change the sample's package name! See README.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:850)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Please change the sample's package name! See README.
at com.example.android.trivialdrivesample.MainActivity.onCreate(MainActivity.java:146)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
... 11 more
01-06 20:13:00.804 1386-1520/? W/ActivityManager: Force finishing activity com.example.android.trivialdrivesample/.MainActivity
01-06 20:13:00.804 1386-1520/? W/ActivityManager: Force finishing activity com.digitalmediarevolutions.kfmobiledesktop/.activities.MainActivity
アプリの強制終了を防ぐにはどうすればよいですか?