UncaughtException
suggest changeIf you want to handle uncaught exceptions, set a handler in the onCreate method of your Application class. This replaces the default handler, which would otherwise terminate the process:
public class MyApp extends Application {
@Override
public void onCreate() {
super.onCreate();
try {
Thread
.setDefaultUncaughtExceptionHandler(
new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable e) {
Log.e(TAG, "Uncaught Exception thread: " + thread.getName(), e);
handleUncaughtException (thread, e);
}
});
} catch (SecurityException e) {
Log.e(TAG, "Could not set the Default Uncaught Exception Handler", e);
}
}
private void handleUncaughtException (Thread thread, Throwable e){
Log.e(TAG, "uncaughtException:");
e.printStackTrace();
}
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents