## 1.添加Jar包
## 2.创建Application子类,并且到清单中注册
## 3.清单中注册网络权限
## 4.配置ACRA对初始化方式
~~~
//copy到继承的Application类中
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
// The following line triggers the initialization of ACRA
ACRA.init(this);
}
~~~
## 5.配置错误报告网络提交的地址
~~~
@ReportsCrashes(formUri = "网络提交地址")
public class MyApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
// The following line triggers the initialization of ACRA
ACRA.init(this);
}
}
~~~
## 配置Toast提示
### 1. Application配置注解
~~~
@ReportsCrashes(
formUri = "网络提交地址",
mode = ReportingInteractionMode.TOAST,
resToastText = R.string.crash_toast_text)
~~~
### 2. 添加String内容
~~~
<string name="crash_toast_text">Ooooops ! I crashed, but a report has been sent to my developer to help fix the issue !</string>
~~~
## 配置Dialog提示
### 1. Application配置注解
~~~
@ReportsCrashes(
formUri = "网络提交地址",
mode = ReportingInteractionMode.DIALOG,
resToastText = R.string.crash_toast_text,
resDialogText = R.string.crash_dialog_text,
resDialogTitle = R.string.crash_dialog_title,
resDialogCommentPrompt = R.string.crash_dialog_comment_prompt,
resDialogOkToast = R.string.crash_dialog_ok_toast
)
~~~
### 2. 添加String内容
~~~
<string name="crash_toast_text">Ooooops ! I crashed, but a report has been sent to my developer to help fix the issue !</string>
<string name="crash_dialog_title">CrashTest has crashed</string>
<string name="crash_dialog_text">An unexpected error occurred forcing the
application to stop. Please help us fix this by sending us error data,
all you have to do is click OK.</string>
<string name="crash_dialog_comment_prompt">You might add your comments about the problem below:</string>
<string name="crash_dialog_ok_toast">Thank you !</string>
~~~
### 3. 清单中配置Activity
~~~
<activity
android:name="org.acra.CrashReportDialog"
android:excludeFromRecents="true"
android:finishOnTaskLaunch="true"
android:launchMode="singleInstance"
android:process=":error_report"
android:theme="@style/AppBaseTheme.Dialog" >
</activity>
~~~
### 4. 添加主题样式
~~~
<style name="AppTheme.Dialog" parent="AppBaseTheme.Dialog"/>
<!-- normal -->
<style name="AppBaseTheme.Dialog" parent="@android:style/Theme.Dialog"/>
<!-- v11 -->
<style name="AppBaseTheme.Dialog" parent="@android:style/Theme.Holo.Light.Dialog"/>
<!-- v14 -->
<style name="AppBaseTheme.Dialog" parent="@android:style/Theme.Holo.Light.Dialog"/>
~~~
## 2.创建Application子类,并且到清单中注册
## 3.清单中注册网络权限
## 4.配置ACRA对初始化方式
~~~
//copy到继承的Application类中
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
// The following line triggers the initialization of ACRA
ACRA.init(this);
}
~~~
## 5.配置错误报告网络提交的地址
~~~
@ReportsCrashes(formUri = "网络提交地址")
public class MyApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
// The following line triggers the initialization of ACRA
ACRA.init(this);
}
}
~~~
## 配置Toast提示
### 1. Application配置注解
~~~
@ReportsCrashes(
formUri = "网络提交地址",
mode = ReportingInteractionMode.TOAST,
resToastText = R.string.crash_toast_text)
~~~
### 2. 添加String内容
~~~
<string name="crash_toast_text">Ooooops ! I crashed, but a report has been sent to my developer to help fix the issue !</string>
~~~
## 配置Dialog提示
### 1. Application配置注解
~~~
@ReportsCrashes(
formUri = "网络提交地址",
mode = ReportingInteractionMode.DIALOG,
resToastText = R.string.crash_toast_text,
resDialogText = R.string.crash_dialog_text,
resDialogTitle = R.string.crash_dialog_title,
resDialogCommentPrompt = R.string.crash_dialog_comment_prompt,
resDialogOkToast = R.string.crash_dialog_ok_toast
)
~~~
### 2. 添加String内容
~~~
<string name="crash_toast_text">Ooooops ! I crashed, but a report has been sent to my developer to help fix the issue !</string>
<string name="crash_dialog_title">CrashTest has crashed</string>
<string name="crash_dialog_text">An unexpected error occurred forcing the
application to stop. Please help us fix this by sending us error data,
all you have to do is click OK.</string>
<string name="crash_dialog_comment_prompt">You might add your comments about the problem below:</string>
<string name="crash_dialog_ok_toast">Thank you !</string>
~~~
### 3. 清单中配置Activity
~~~
<activity
android:name="org.acra.CrashReportDialog"
android:excludeFromRecents="true"
android:finishOnTaskLaunch="true"
android:launchMode="singleInstance"
android:process=":error_report"
android:theme="@style/AppBaseTheme.Dialog" >
</activity>
~~~
### 4. 添加主题样式
~~~
<style name="AppTheme.Dialog" parent="AppBaseTheme.Dialog"/>
<!-- normal -->
<style name="AppBaseTheme.Dialog" parent="@android:style/Theme.Dialog"/>
<!-- v11 -->
<style name="AppBaseTheme.Dialog" parent="@android:style/Theme.Holo.Light.Dialog"/>
<!-- v14 -->
<style name="AppBaseTheme.Dialog" parent="@android:style/Theme.Holo.Light.Dialog"/>
~~~