2015-12-17 2 views
2

Comment configurer un champ CUSTOM_DATA avec un couchdb?ACRA envoyant une donnée personnalisée REPORTFIELD

Je veux définir une valeur de configuration à envoyer avec l'erreur. Dans le fond, j'ai un canapé db avec une application web ACLARYZER.

Ceci est le code sur ma classe Application.class dans Android où j'ai défini cette valeur de données personnalisée.

@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); 


} 
} 

Maintenant, la question est comment ajouter de la valeur dans le canapé db pour obtenir ce champ de données personnalisées. Ou je dois définir les données personnalisées dans l'ACRALYZER?

merci

Répondre

2

Enfin, c'est plus facile que je ne peux l'imaginer.

Il suffit de mettre cette ligne avec tous les CUSTOM_DATA

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

Ensuite, votre code est somthing comme ça.

@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"); 
} 

L'ACLARYZER fait le reste.