How to override settings of ACRA in Android

2019-05-09 13:13发布

on my Application-Class I defined a ACRA with these annotations

@ReportsCrashes(formKey = "",
            mailTo = "my@email.de",
            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.
)
public class AttachApplication extends Application implements OnSharedPreferenceChangeListener{

this works fine, but also I have button in my app where the user can send an error report manually. For that I want to change mode, so that only an email will be sent instead of a Dialog.

public void startSendErrorAction(View view) {
    Log.d( TAG, "sending error to srs" );
    ACRAConfiguration config = ACRA.getConfig();
    int prevDialogTitle = config.resDialogTitle();
    int prevDialogText = config.resDialogText();
    config.setResDialogTitle( R.string.manual_error_title );
    config.setResDialogText( R.string.manual_error_text );

    ACRA.setConfig( config );
    ACRA.getErrorReporter().handleException(null);

    config.setResDialogText( prevDialogText );
    config.setResDialogTitle( prevDialogTitle );
    ACRA.setConfig( config );
}

I tried to change only the text and title of the dialog box but this wont work. It always uses the ones which are configured in the annotation.

Is it possible to overrite these values? Thanks

标签: android acra
1条回答
Root(大扎)
2楼-- · 2019-05-09 14:09

I think you want somethin like ACRA: sometimes dialog report and other times silent report but in the "opposite" direction. So first use SILENT in the configuration and reset it with DIALOG before setting the configuration.

查看更多
登录 后发表回答