Ideal way to set global uncaught exception Handler in Android

Posted by Samuh on Stack Overflow See other posts from Stack Overflow or by Samuh
Published on 2010-05-04T10:12:52Z Indexed on 2010/05/04 21:08 UTC
Read the original article Hit count: 229

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.

© Stack Overflow or respective owner

Related posts about android

Related posts about exception-handling