Skip to content

Instantly share code, notes, and snippets.

@fbcbl
Last active May 13, 2019 13:31
Show Gist options
  • Save fbcbl/6d34939165c5f2ea893a9969a1d0be29 to your computer and use it in GitHub Desktop.
Save fbcbl/6d34939165c5f2ea893a9969a1d0be29 to your computer and use it in GitHub Desktop.
Crash Handling Part 1
private fun setupCrashHandler() {
// 1. Get the system handler.
val systemHandler = Thread.getDefaultUncaughtExceptionHandler()
// 2. Set the default handler as a dummy (so that crashlytics fallbacks to this one, once set)
Thread.setDefaultUncaughtExceptionHandler { t, e -> /* do nothing */ }
// 3. Setup crashlytics so that it becomes the default handler (and fallbacking to our dummy handler)
Fabric.with(this, Crashlytics())
val fabricExceptionHandler = Thread.getDefaultUncaughtExceptionHandler()
// 4. Setup our handler, which tries to restart the app.
Thread.setDefaultUncaughtExceptionHandler(AppExceptionHandler(systemHandler, fabricExceptionHandler, this))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment