CROSP
CROSP

Reputation: 4617

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

I am trying to send ACRA exception report, without closing app, but it still closes the app and show the dialog.

I am sending exception report like this.

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

Second argument is responsible for closing app. But it still show dialog and app closes anyway.

Here is my configuration, but I don't think it will be useful

@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"
)

Maybe I am doing something wrong, how to just send report in background and don't notify user.

Thanks.

EDIT

I have read source code and found only one way to do this.

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

But it seems to be another better way to do this.

Upvotes: 3

Views: 1364

Answers (1)

William
William

Reputation: 20196

ACRA.getErrorReporter().handleSilentException(e);

It's part of the ACRA Wiki.

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

Upvotes: 5

Related Questions