Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
485 views
in Technique[技术] by (71.8m points)

android - How to show a Dialog after crash by using Crashlytics?

How to show a Dialog after crash by using Crashlytics.

for example: after crash I need open a dialog where user will put any comment(note) how he did that crash.

Is any option in Crashlytics?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Yes, definitely. It's also extremely easy.

Crashlytics.getInstance().setListener(new CrashlyticsListener() {
  @Override
  public void crashlyticsDidDetectCrashDuringPreviousExecution() {
    // now it's the right time to show the dialog
  }
});
Crashlytics.start(context);

EDIT (Deprecated as of July 2015)

If you're using the new Fabric integration, the code is slightly different (as seen here). It should look like this:

Fabric.with(this, new Crashlytics());
Crashlytics.getInstance().setListener(new CrashlyticsListener() {
  @Override
  public void crashlyticsDidDetectCrashDuringPreviousExecution() {
    // now it's the right time to show the dialog
  }
});

EDIT 2 (The latest Fabric SDKs have deprecated the setMethods)

final CrashlyticsListener listener = new CrashlyticsListener() {
            @Override
            public void crashlyticsDidDetectCrashDuringPreviousExecution(){
                  // now it's the right time to show the dialog
            }
        };

final CrashlyticsCore core = new CrashlyticsCore
                                  .Builder()
                                  .listener(listener)
                                  .build();

Fabric.with(this, new Crashlytics.Builder().core(core).build());

To test your integration, you can simply call Crashlytics.getInstance().crash(). Simple but handy.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...