I am thinking of setting up a global, default Exception handler for my (Android) Mobile application using Thread.setDefaultUncaughtExceptionHandler(...) call. I am thinking of just displaying an Alert Dialog with appropriate message to the user.
Are there any gotchas, caveats and rules that one needs to follow when setting a DefaultExceptionHandlers? Any best practices like making sure that the process is killed, full stack trace is written to logs etc. ?
Links to documentation, tutorials etc. that can throw some light on this are welcome.
You don't need to clean up any processes; once the uncaughtException method finishes that thread ends and the JVM will clean up as default. You could print the stack trace if you'd like to but there is no need for it. In the end, you can do whatever you want - print the exception, show a dialog*, write the exception to a log file, a combination of the previous three, anything else - as long as it doesn't throw any exceptions.
* Keep in mind to make sure to show the dialog on the Event Dispatcher Thread!