I have integrated Firebase Crashlytics version 2.9.1 to digging out crashes to cover performance and stability of my app.
Crashes are not being logged on firebase crashlytics console if application is having own UncaughtExceptionHandler.
I have BaseActivity in my app. inside onCreate() method I have registered custom UncaughtExceptionHandler based on project requirement.
Whenever app got crashed due to any reason, user should be redirected to splash screen (MainActivity.java
) .
public class BaseActivity extends FragmentActivity{
@Override
protected void onCreate(Bundle arg0) {
// Enable global crash handler.
Thread.setDefaultUncaughtExceptionHandler(handleAppCrash);
}
/***
* @Purpose Called when any crash occurs in the application.
***/
private Thread.UncaughtExceptionHandler handleAppCrash = new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
Intent intent = new Intent(context, MainActivity.class); //redirect to Splash screen
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(intent);
System.exit(0);
}
};
}