【问题标题】:ACRA sending a custom data REPORTFIELDACRA 发送自定义数据 REPORTFIELD
【发布时间】:2015-12-17 15:28:51
【问题描述】:

如何使用 couchdb 配置 CUSTOM_DATA 字段?

我想设置一个配置值与错误一起发送。在后端,我有一个带有 ACLARYZER 网络应用程序的沙发数据库。

这是我在 Android 中的 Application.class 上定义此自定义数据值的代码。

@ReportsCrashes(
    formUri = "https://user.cloudant.com/acra-report/_design/acra-storage/_update/report",
    reportType = HttpSender.Type.JSON,
    httpMethod = HttpSender.Method.POST,
    formUriBasicAuthLogin = "user",
    formUriBasicAuthPassword = "pass",
    formKey = "", // This is required for backward compatibility but not used
    customReportContent = {
            ReportField.APP_VERSION_CODE,
            ReportField.APP_VERSION_NAME,
            ReportField.ANDROID_VERSION,
            ReportField.PACKAGE_NAME,
            ReportField.REPORT_ID,
            ReportField.BUILD,
            ReportField.STACK_TRACE,
            ReportField.CUSTOM_DATA
    },
    mode = ReportingInteractionMode.TOAST,
    resToastText = R.string.reporte_error
)
public class my_applicaction  extends Application{

 @Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
    ACRA.init(my_applicaction.this);
    ACRA.getErrorReporter().putCustomData("myKey", "myValue");
    ACRA.getErrorReporter().handleException(null);


}
}

现在问题是如何在沙发数据库中添加值来获取这个自定义数据字段。或者我必须在 ACRALYZER 中定义自定义数据?

谢谢

【问题讨论】:

  • 嗨@exequielc。您使用的是什么版本的 Acra?
  • 编译'ch.acra:acra:4.5.0'

标签: java android couchdb acra acralyzer


【解决方案1】:

终于比我想象的要容易了。

只需将此行与每个 CUSTOM_DATA 放在一起

 ACRA.getErrorReporter().putCustomData("NAME_VALUE1", "VALUE1");

那么你的代码就是这样的。

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    ACRA.init(Application.this);
    ACRA.getErrorReporter().putCustomData("NAME_VALUE1", "VALUE1");
    ACRA.getErrorReporter().putCustomData("NAME_VALUE2", "VALUE2");
    ACRA.getErrorReporter().putCustomData("NAME_VALUE3", "VALUE3");
}

ACLARYZER 完成剩下的工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-14
    • 2017-08-19
    • 1970-01-01
    相关资源
    最近更新 更多