如何在Android中覆盖ACRA的设置

4
在我的应用程序类中,我使用这些注释定义了一个ACRA。
@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{

这个功能已经正常工作,但是我在应用程序中有一个按钮,用户可以手动发送错误报告。为此,我想更改模式,只发送电子邮件而不是弹出对话框。

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

我试图仅更改对话框的文本和标题,但这不起作用。它总是使用在注释中配置的内容。

是否可能覆盖这些值? 谢谢


也许一个选项是基于一些额外的输入,使对话框显示在您的“ErrorReportter”类中。我已经用静默/非静默错误做到了这一点。 - Boris Strandjev
你有相关的示例代码吗?我尝试了但是不起作用,出现了一个异常,提示ResToastText未设置,虽然我在我的代码中已经设置了。 - Al Phaba
不好意思,我没有。不过,我可以尝试帮助你。请添加代码,这样我就可以尝试帮忙了。 - Boris Strandjev
1个回答

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接