如何使用Crashlytics在崩溃后显示对话框?

Nic*_*hek 6 android dialog crashlytics

如何使用Crashlytics在崩溃后显示Dialog.

例如:崩溃后我需要打开一个对话框,用户将在其中发表任何评论(注释)他是如何进行崩溃的.

Crashlytics有什么选择吗?

Seb*_*ano 13

当然是.这也非常容易.

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

编辑(截至2015年7月已弃用)

如果您正在使用新的Fabric集成,则代码略有不同(如此处所示).它应该如下所示:

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

编辑2(最新的Fabric SDK已弃用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());
Run Code Online (Sandbox Code Playgroud)

要测试您的集成,您只需致电Crashlytics.getInstance().crash().简单但方便.