On Oct 1, 2:18 am, fadden <[email protected]> wrote:
> If you're trying to do this when an activity is created: have a static
> "has been initialized" member variable; if it's false, get the current
> default uncaught exception handler and save it away. Set yours. When
> your handler is called, do the processing, and then call the original
> (unless you really don't want the default behavior).
I do this in a static initializer in the main activity class. This way
there is no need for a static flag:
final UncaughtExceptionHandler ueh =
Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler
() {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
// ...
// MY STUFF GOES HERE (for example, grab the Build.MODEL and
Build.ID and then report it using analytics)
// ...
ueh.uncaughtException(thread, ex);
}
});
I'm not sure how safe this is, because in theory the default exception
handler could change in between these two statements but I think its
very unlikely, if not impossible!
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en