问题描述
在我的应用程序类上,我定义了带有这些批注的ACRA
on my Application-Class I defined a ACRA with these annotations
@ReportsCrashes(formKey = "",
mailTo = "[email protected]",
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
推荐答案
我认为您需要类似,但方向相反。
因此,在设置配置之前,请先在配置中使用SILENT并使用DIALOG将其重置。
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.
这篇关于如何在Android中覆盖ACRA设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!