標題翻譯的很差,你們有以爲更合適的歡迎下面評論android
先看幾張張圖:git
dependencies { compile 'cat.ereza:customactivityoncrash:1.3.0' }
<activity android:name="cat.ereza.customactivityoncrash.activity.DefaultErrorActivity" android:label="@string/customactivityoncrash_error_activity_error_details_title" android:process=":error_activity" > <intent-filter> <action android:name="cat.ereza.customactivityoncrash.ERROR" /> </intent-filter> </activity>
@Override public void onCreate() { super.onCreate(); //Install CustomActivityOnCrash CustomActivityOnCrash.install(this); //Now initialize your error handlers as normal //i.e., ACRA.init(this); //or Crashlytics.start(this); }
注意:若是你已經有ACRA,Crashlytics或任何相似的庫在您的應用程序,它仍然會正常工做,但CustomActivityOnCrash必須先初始化,或原始報告工具將中止工做。github
在程序中添加下面一行代碼,必須保證他能被執行ide
throw new RuntimeException("Boom!");
在CustomActivityOnCrash.install(this)以後調用工具
設置ErrorActivity在後臺啓動,默認爲true測試
CustomActivityOnCrash.setLaunchErrorActivityWhenInBackground(boolean);
設置展現詳細錯誤信息,默認爲truethis
CustomActivityOnCrash.setShowErrorDetails(boolean);
啓用APP Restart,默認爲truespa
CustomActivityOnCrash.setEnableAppRestart(boolean);
設置從新啓動的activity翻譯
CustomActivityOnCrash.setRestartActivityClass(Class<? extends Activity>);
自定義請參閱Github:https://github.com/Ereza/CustomActivityOnCrashcode
注:若是使用Android Studio添加compile無效的話,建議下載library以module的形式添加依賴