【问题标题】:How to override settings of ACRA in Android如何在 Android 中覆盖 ACRA 的设置
【发布时间】:2013-01-01 05:00:33
【问题描述】:

在我的应用程序类中,我使用这些注释定义了一个 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 类中显示对话框。我已经通过静默/非静默错误做到了这一点。
  • 你有示例代码吗?我试过了,但没有用,出现了 ResToastText 没有设置的异常,虽然我在我的代码中做到了
  • 不,对不起,我没有。不过,我可能会尽力帮助你。能否请您添加代码,以便我可以尝试提供帮助。

标签: android acra


【解决方案1】:

我认为你想要像ACRA: sometimes dialog report and other times silent report 这样的东西,但在“相反”的方向。 所以首先在配置中使用 SILENT 并在设置配置之前使用 DIALOG 重置它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-22
    • 1970-01-01
    • 2022-10-23
    • 1970-01-01
    • 2014-06-01
    • 2011-07-13
    • 2014-06-12
    • 2015-11-04
    相关资源
    最近更新 更多