Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Basically, you have to implement your own instance of an <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.UncaughtExceptionHandler.html" rel="nofollow noreferrer">UncaughtExceptionHandler</a>, then you will have to make sure that for every thread your App runs you call <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.html#setUncaughtExceptionHandler%28java.lang.Thread.UncaughtExceptionHandler%29" rel="nofollow noreferrer">setUncaughtExceptionHandler</a>.</p> <p>Then, when an uncaught exception occurs in any of those threads, your own <code>UncaughtExceptionHandler</code> will be called and you can from there schedule your App's restart or whatever before passing on the exception.</p> <p>I don't know if it really makes sense to just restart the App in that case, though. The user may be quite "surprised" if, in the middle of his interaction, the App 'resets' and does not resume where it was just a second ago, possibly even losing the user's previous input, etc..</p> <p><em>Edit:</em></p> <p>See <a href="https://stackoverflow.com/questions/2681499/android-how-to-auto-restart-application-after-its-been-force-closed">here</a>, the answer of Gyuri. Apart from that you only need to <em>implement an interface</em>, namely <code>UncaughtExceptionHandler</code>, and 'paste' Gyuri's code into that. </p> <p><em>Edit #2:</em></p> <p>For reference: A service started <a href="http://developer.android.com/reference/android/app/Service.html#START_STICKY" rel="nofollow noreferrer">"sticky"</a> might achieve the desired result, too.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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