Skip to content

Instantly share code, notes, and snippets.

@banasiak
Created January 16, 2018 22:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save banasiak/db1f59889162dcc6798659486a3e1014 to your computer and use it in GitHub Desktop.
Save banasiak/db1f59889162dcc6798659486a3e1014 to your computer and use it in GitHub Desktop.
Absolute last chance to log an exception and it's stack trace to logcat for an Android app.
public class MyApplication extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
if(BuildConfig.DEBUG) {
final Thread.UncaughtExceptionHandler handler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(
(t, e) -> {
Timber.wtf(e);
handler.uncaughtException(t, e);
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment