ACRA is a library enabling Android Application to automatically post their crash reports to a GoogleDoc form. It is targetted to android applications developers to help them get data from their applications when they crash or behave erroneously.
ACRA is used in 2.68% (See AppBrain/stats) of all apps on Google Play as of Feb 2016. That’s over 53K apps using ACRA. And since the average US user has 41 apps installed on their phone that means there is a 70% chance that ACRA is running on any phone. That means ACRA is running on over a billion devices.
ACRA是1個自動搜集崩潰日志到谷歌表單的庫。它幫助安卓開發者在他們程序崩潰或運行毛病時獲得異常數據。
截止2016年2月,ACRA在google play中使用率占2.68%。這意味著有53K款app使用了ACRA。由于美國用戶平均有41的利用程序安裝在手機上,意味著ACRA在每臺手機上運行的幾率為70%。這意味著運行著ACRA的裝備超過10億臺。
ACRA是1個開源的Android平臺程序崩潰信息搜集小程序,可以嵌入到Android Project中,當該程序崩潰的時候ACRA能夠在進程完全結束前搜集崩潰狀態時的該利用和裝備的各種信息,發送到搭建好的服務端,便于開發者進行程序毛病信息的搜集,開發者可以更好的改進程序提高兼容性。
官網 http://www.acra.ch/
crash 以toast情勢彈出
//發送到服務器,Toast情勢
@ReportsCrashes(formUri = "http://192.168.1.160/AcraServiceDemo/CrashApiAction",
//formUriBasicAuthLogin = "yourlogin", // optional
//formUriBasicAuthPassword = "y0uRpa$$w0rd", // optional
mode = ReportingInteractionMode.TOAST,
reportType= HttpSender.Type.JSON,//配置以json情勢發送
resToastText=R.string.crash_toast_text)//配置異常時彈出的信息
對話框情勢情勢,會提示用戶輸入上報信息。
@ReportsCrashes(formUri = "http://192.168.1.160/AcraServiceDemo/CrashApiAction",
mode = ReportingInteractionMode.DIALOG,
resToastText = R.string.crash_toast_text2, // optional, displayed as soon as the crash occurs, before collecting data which can take a few seconds
resDialogText = R.string.crash_dialog_text,
resDialogIcon = android.R.drawable.ic_dialog_info, //optional. default is a warning sign
resDialogTitle = R.string.crash_dialog_title, // optional. default is your application name
resDialogCommentPrompt = R.string.crash_dialog_comment_prompt, // optional. When defined, adds a user text field input with this text resource as a label
resDialogOkToast = R.string.crash_dialog_ok_toast, // optional. displays a Toast message when the user accepts to send a report.
resDialogTheme = R.style.AppTheme_Dialog, //optional. default is Theme.Dialog
reportType = HttpSender.Type.JSON//配置以json情勢發送
)
通知欄情勢,點擊變成對話框情勢
// 發送到服務器,通知欄情勢,點擊跳進對話框情勢搜集用戶輸入的信息,會提示用戶輸入上報信息。官方已不再提倡使用:This is a legacy feature, as Dialog mode is generally preferred.
@ReportsCrashes(formUri = "http://192.168.1.160/AcraServiceDemo/CrashApiAction",
mode = ReportingInteractionMode.NOTIFICATION,
resToastText = R.string.crash_toast_text2, // optional, displayed as soon as the crash occurs, before collecting data which can take a few seconds
resDialogText = R.string.crash_dialog_text,
resDialogIcon = android.R.drawable.ic_dialog_info, //optional. default is a warning sign
resDialogTitle = R.string.crash_dialog_title, // optional. default is your application name
resDialogCommentPrompt = R.string.crash_dialog_comment_prompt, // optional. When defined, adds a user text field input with this text resource as a label
resDialogOkToast = R.string.crash_dialog_ok_toast, // optional. displays a Toast message when the user accepts to send a report.
resDialogTheme = R.style.AppTheme_Dialog, //optional. default is Theme.Dialog
resNotifTickerText = R.string.crash_notif_ticker_text,
resNotifTitle = R.string.crash_notif_title,
resNotifText = R.string.crash_notif_text,
resNotifIcon = android.R.drawable.stat_notify_error, // optional. default is a warning sign
reportType = HttpSender.Type.JSON//配置以json情勢發送
)
發送郵箱,注意:該操作觸發時會調起用戶客戶端郵箱需要用戶主動發送。不建議使用。
@ReportsCrashes(mailTo = "414850132@qq.com",
customReportContent = {ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME,
ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL, ReportField.CUSTOM_DATA,
ReportField.STACK_TRACE, ReportField.LOGCAT},//發送的字段
mode = ReportingInteractionMode.TOAST,//異常時彈出信息的類型
resToastText = R.string.crash_toast_text)//彈出的文字
// Control
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF⑻");
response.setContentType("text/html; charset=UTF⑻");
response.getWriter().print("begin");
ServletInputStream inputStream = request.getInputStream();
String str = IOUtils.toString(inputStream, "UTF⑻");//json情勢接收
System.out.println(str);
System.out.println("開始解析");
processModel(str);
}