Android ACRA自定义ReportSender发送方法调用两次

时间:2015-10-06 10:45:54

标签: java android acra

我想在我的Android应用程序中添加crashlogging,我决定使用ACRA库(版本4.6.1)。我写了一个自定义报告发件人调用webmethods服务(我的应用程序的后端)。出于某种原因,使用相同的CrashReportData对象调用我的ReportSender的send方法两次。我添加了将app崩溃到其中一个按钮调用的方法的代码,而button方法只调用一次。我怀疑应用程序第二次从库代码中崩溃,但调试器不会在send方法内的断点处停止,所以我不能确定。这是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();
}

`

谢谢!

1 个答案:

答案 0 :(得分:0)

在报告崩溃两次时显示您的Android日志。 可能是因为它的设备无法第一次发送,所以它重新发送。如果客户端与服务器的连接超时,则会发生这种情况。您可以通过调整套接字超时来缓解这种情况。

https://github.com/ACRA/acra/wiki/AdvancedUsage#adjusting-the-socket-timeout

相关问题