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);
}