Search code examples
androidexceptioncrashlyticsgoogle-fabriccrashlytics-android

Crashlytics and default exception handler


I am using crashlytics for my android project, my requirement is that upon an app crash, I want to my own custom feedback activity and I also want to log this as a fatal exception in crashlytics. I tried approaches in the accepted answer : Crashlytics Android SDK - custom UncaughtExceptionHandler , but asynchronous initialization did not succeed for me. So, I tried initializing synchronously, like:

Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
    @Override
    public void uncaughtException(Thread thread, Throwable ex) {

      // launch feed back activity
      Intent intent = new Intent();
      intent.setAction("com.project.SEND_LOG");
      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      startActivity(intent);


      defaultUncaughtExceptionHandler.uncaughtException(thread, ex);
    }
  });

But this does not launch the feedback activity (though the code for launching feedback activity is executed), instead it shows the default app crashing behaviour in android. Can someone please help me with this ?


Solution

  • Thanks. This is not officially supported by Crashlytics. If you do find a workaround we cannot ensure that it will continue to work over time with updates to our SDK.