I found this Android: How to auto-restart application after it's been "force closed"?
but I don\'t know where and how to put the alarm manager
Basically, you have to implement your own instance of an UncaughtExceptionHandler, then you will have to make sure that for every thread your App runs you call setUncaughtExceptionHandler.
Then, when an uncaught exception occurs in any of those threads, your own UncaughtExceptionHandler
will be called and you can from there schedule your App's restart or whatever before passing on the exception.
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..
Edit:
See here, the answer of Gyuri. Apart from that you only need to implement an interface, namely UncaughtExceptionHandler
, and 'paste' Gyuri's code into that.
Edit #2:
For reference: A service started "sticky" might achieve the desired result, too.