Last active
May 13, 2019 13:31
-
-
Save fbcbl/6d34939165c5f2ea893a9969a1d0be29 to your computer and use it in GitHub Desktop.
Crash Handling Part 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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