gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 10:50:15 30 4
gpt4 key购买 nike

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

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com