Skip to content

Commit

Permalink
Added unhandled excpetion logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
zamojski committed May 28, 2016
1 parent f11cdd3 commit a1fe0ea
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class MyApplication extends Application {
private static MyApplication application;
private static PreferencesProvider prefProvider;

private static Thread.UncaughtExceptionHandler defaultHandler;

private static int appTheme;

private static String backgroundTaskName = null;
Expand All @@ -50,10 +52,23 @@ public void onCreate() {
initLogger();
initEventBus();
initACRA();
// Exception handling must be initialized after ACRA to obtain crash details
initUnhandledExceptionHandler();
initTheme();
initGA();
}

private void initUnhandledExceptionHandler() {
defaultHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
Log.e("CRASHED", ex);
defaultHandler.uncaughtException(thread, ex);
}
});
}

public void initLogger() {
// Default configuration
Log.usePrinter(Log.ANDROID, true).level(Log.I).useFormat(true);
Expand Down

0 comments on commit a1fe0ea

Please sign in to comment.