本文介紹了如何使用 Crashlytics 在崩潰后顯示對話框?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
如何使用 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.
Crashlytics 中有任何選項嗎?
Is any option in Crashlytics?
推薦答案
是的,當然.這也非常簡單.
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);
編輯(2015 年 7 月已棄用)
如果您使用的是新的 Fabric 集成,則代碼會略有不同(此處所示).它應該是這樣的:
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(最新的 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()
.簡單但方便.
這篇關于如何使用 Crashlytics 在崩潰后顯示對話框?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!