Crash app in Thread.setDefaultUncaughtExceptionHandler
I would like to crash my app on purpose after logging my own error. The
Handler is registered in Application.onCreate():
// set global exception handler
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, final Throwable ex) {
// unregister
Thread.setDefaultUncaughtExceptionHandler(null);
// do report ...
// crash app -does not work, app is frozen
if (ex instanceof RuntimeException)
throw (RuntimeException) ex;
throw new RuntimeException("Re-throw", ex);
}
However, my app freezes instead of crashing with a dialog. How can I crash
the application as it would if I hadn't registered the handler?
No comments:
Post a Comment