解决方法
当然是.这也非常容易.
Crashlytics.getInstance().setListener(new CrashlyticsListener() { @Override public void crashlyticsDidDetectCrashDuringPrevIoUsExecution() { // now it's the right time to show the dialog } }); Crashlytics.start(context);
编辑(截至2015年7月已弃用)
如果您正在使用新的Fabric集成,则代码略有不同(as seen here).它应该如下所示:
Fabric.with(this,new Crashlytics()); Crashlytics.getInstance().setListener(new CrashlyticsListener() { @Override public void crashlyticsDidDetectCrashDuringPrevIoUsExecution() { // now it's the right time to show the dialog } });
编辑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());
要测试集成,只需调用Crashlytics.getInstance().crash()即可.简单但方便.