Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to let the process just die when child activity throws an uncaught exception
    text
    copied!<p>Activity <code>A</code> starts a child activity <code>B</code>, if <code>B</code> fails with an uncaught exception, it closes and Android system starts the parent activity <code>A</code> in a new process. Now, everything would be fine if that parent activity starts with a fresh state but it doesn't. The state of the activity is restored somehow even though it's a new process. This causes a whole lot of problems.</p> <p>Reading similar questions, this is what I've tried so far:</p> <p><b>In child activity:</b></p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandle() { public void uncaughtException(Thread thread, Throwable ex) { // replacing the following 5 with just finish() doesn't help // either because then the screen just goes all black final Intent rootActivity = new Intent(getApplicationContext(), RootActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(rootActivity); android.os.Process.killProcess(android.os.Process.myPid()); System.exit(0); return; } }; ... ... ... } </code></pre> <p>Other thing I tried is setting <code>android:multiProcess="false"</code> for the parent activity...doesn't change anything.</p> <p>Android system still starts the parent activity (in a new process) and executes onRestoreInstance.</p> <p>I would like the application to die completely with an "Unexpected error occured" or whatever system dialog and not restart at all.</p> <p>Please help, it's driving me nuts.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload