我想将崩溃日志添加到我的 Android 应用程序中,我决定使用 ACRA 库(版本 4.6.1)。我编写了一个调用 webmethods 服务(我的应用程序的后端)的自定义报告发送器。由于某种原因,我的 ReportSender 的 send 方法被使用相同的 CrashReportData 对象调用两次。我添加了使应用程序崩溃的代码到其中一个按钮调用的方法,并且该按钮方法仅被调用一次。我怀疑应用程序从库代码内部第二次崩溃,但调试器不会在发送方法内的断点处停止,所以我不能确定。以下是 ACRA 初始化的代码:
@ReportsCrashes(
mode = ReportingInteractionMode.DIALOG,
resToastText = R.string.crash_toast_text, // 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.
customReportContent = { ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME, ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL, ReportField.CUSTOM_DATA, ReportField.STACK_TRACE, ReportField.LOGCAT, ReportField.USER_COMMENT } )
public class MHABApplication extends Application
{
@Override
public void onCreate() {
// The following line triggers the initialization of ACRA
ACRA.init(this);
CrashESBReportSender esbSender = new CrashESBReportSender();
ACRA.getErrorReporter().setReportSender(esbSender);
super.onCreate();
}
`
谢谢!
最佳答案
当崩溃报告两次时显示您的 Android 日志。 可能是设备第一次无法发送,因此重新发送。如果客户端与服务器的连接超时,就会发生这种情况。您可以通过调整套接字超时来缓解这种情况。
https://github.com/ACRA/acra/wiki/AdvancedUsage#adjusting-the-socket-timeout
关于java - Android ACRA 自定义 ReportSender 发送方法调用两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32968014/