I want to set a global uncaught exception handler for all the threads in my Android application. So, in my Application
subclass I set an implementation of Thread.UncaughtExceptionHandler
as default handler for uncaught exceptions.
Thread.setDefaultUncaughtExceptionHandler(
new DefaultExceptionHandler(this));
In my implementation, I am trying to display an AlertDialog
displaying appropriate exception message.
However, this doesn't seem to work. Whenever, an exception is thrown for any thread which goes un-handled, I get the stock, OS-default dialog (Sorry!-Application-has-stopped-unexpectedly dialog).
What is the correct and ideal way to set a default handler for uncaught exceptions?
Thanks.