标题翻译的很差,你们有以为更合适的欢迎下面评论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的形式添加依赖