-
Notifications
You must be signed in to change notification settings - Fork 5
Log System Crashes
Muhammad Umair Adil edited this page Sep 12, 2018
·
1 revision
Add this to onCreate of Application class to auto catch system crashes. This also works with Crashlytics. Source Medium Article: Hide your crashes gracefully (and still report them)
class MainApplication : Application() {
override fun onCreate() {
super.onCreate()
setupCrashHandler()
}
private fun setupCrashHandler() {
val systemHandler = Thread.getDefaultUncaughtExceptionHandler()
Thread.setDefaultUncaughtExceptionHandler { t, e -> /* do something here */ }
Fabric.with(this, Crashlytics())
val fabricExceptionHandler = Thread.getDefaultUncaughtExceptionHandler()
Thread.setDefaultUncaughtExceptionHandler(AppExceptionHandler(systemHandler, fabricExceptionHandler, this))
}
}