android - 如何在 Android 中覆盖 ACRA 的设置

标签 android acra

在我的应用程序类上,我用这些注释定义了一个 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 );
}

我试图只更改对话框的文本和标题,但这行不通。它始终使用注释中配置的那些。

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

最佳答案

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

关于android - 如何在 Android 中覆盖 ACRA 的设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14382750/

相关文章:

android - 为什么不同的 Activity 在 Android 中显示为单独的应用程序

java - 下载管理器下载失败

json - org.json.JSONObject 与 javax.json.JsonObject?

android - ACRA 在 CrashReports.csv 文件中不显示任何内容

android - 当我的应用程序崩溃时如何设置自定义对话框?

Android ACRA 未报告崩溃

java - 如何以用户友好的方式使用 GoogleDocs 查看 ACRA 异常(exception)情况?

Android每5分钟运行一次的方法

android - 我如何阻止或避免 webview 中的弹出窗口?

android - 为什么/何时使用 realm.beginTransaction?由于有executeTransaction和executeTransactionAsync