如何在不关闭APP(甚至显示对话框)的情况下发送ACRA异常报告

How to send ACRA exception report without closing APP (even showing dialog)

我试图在不关闭应用程序的情况下发送 ACRA 异常报告,但它仍然关闭应用程序并显示对话框。

我正在发送这样的异常报告。

   ACRA.getErrorReporter().handleException(finalException, false);

第二个参数负责关闭应用程序。 但它仍然显示对话框并且应用程序无论如何都会关闭。

这是我的配置,但我认为它不会有用

@ReportsCrashes(
        reportType = org.acra.sender.HttpSender.Type.JSON,
        httpMethod = org.acra.sender.HttpSender.Method.POST,
        mode = ReportingInteractionMode.DIALOG,
        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.
        formUri = "aaaaaaaaa",
        formUriBasicAuthLogin = "oooooooo",
        formUriBasicAuthPassword = "bbbbbbbb"
)

也许我做错了什么,如何只在后台发送报告而不通知用户。

谢谢。

编辑

我已经阅读了源代码,发现只有一种方法可以做到这一点。

   ReportingInteractionMode previousMode = ACRA.getConfig().mode();
                try {
                    ACRA.getConfig().setMode(ReportingInteractionMode.SILENT);
                } catch (ACRAConfigurationException e) {
                    e.printStackTrace();
                }
                ACRA.getErrorReporter().handleException(finalException, false);
                try {
                    ACRA.getConfig().setMode(previousMode);
                } catch (ACRAConfigurationException e) {
                    e.printStackTrace();
                }

但这似乎是另一种更好的方法。

ACRA.getErrorReporter().handleSilentException(e);

它是 ACRA Wiki 的一部分。

https://github.com/ACRA/acra/wiki/AdvancedUsage#sending-reports-for-caught-exceptions-or-for-unexpected-application-state-without-any-exception