org.acra.sender
Class HttpPostSender

java.lang.Object
  extended by org.acra.sender.HttpPostSender
All Implemented Interfaces:
ReportSender

public class HttpPostSender
extends Object
implements ReportSender

The ReportSender used by ACRA when ReportsCrashes.formUri() has been defined in order to post crash data to a custom server-side data collection script. It sends all data in a POST request with parameters named with easy to understand names (basically a string conversion of ReportField enum values) or based on your own conversion Map from ReportField values to String.

To use specific POST parameter names, you can provide your own report fields mapping scheme:

 @ReportsCrashes(...)
 public class myApplication extends Application {
 
     public void onCreate() {
         ACRA.init(this);
         Map<ReportField, String> mapping = new HashMap<ReportField, String>();
         mapping.put(ReportField.APP_VERSION_CODE, "myAppVerCode'); 
         mapping.put(ReportField.APP_VERSION_NAME, "myAppVerName');
         //... 
         mapping.put(ReportField.USER_EMAIL, "userEmail');
         // remove any default report sender
         ErrorReporter.getInstance().removeAllReportSenders();
         // create your own instance with your specific mapping
         ErrorReporter.getInstance().addReportSender(new ReportSender("http://my.domain.com/reports/receiver.py", mapping));
         
         
         super.onCreate();
     }
 }
 

Author:
Kevin Gaudin

Constructor Summary
HttpPostSender(Map<ReportField,String> mapping)
           Create a new HttpPostSender instance with its destination taken from ACRA.getConfig() dynamically.
HttpPostSender(String formUri, Map<ReportField,String> mapping)
           Create a new HttpPostSender instance with a fixed destination provided as a parameter.
 
Method Summary
 void send(CrashReportData report)
          Send crash report data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpPostSender

public HttpPostSender(Map<ReportField,String> mapping)

Create a new HttpPostSender instance with its destination taken from ACRA.getConfig() dynamically. Configuration changes to the formUri are applied automatically.

Parameters:
mapping - If null, POST parameters will be named with ReportField values converted to String with .toString(). If not null, POST parameters will be named with the result of mapping.get(ReportField.SOME_FIELD);

HttpPostSender

public HttpPostSender(String formUri,
                      Map<ReportField,String> mapping)

Create a new HttpPostSender instance with a fixed destination provided as a parameter. Configuration changes to the formUri are not applied.

Parameters:
formUri - The URL of your server-side crash report collection script.
mapping - If null, POST parameters will be named with ReportField values converted to String with .toString(). If not null, POST parameters will be named with the result of mapping.get(ReportField.SOME_FIELD);
Method Detail

send

public void send(CrashReportData report)
          throws ReportSenderException
Description copied from interface: ReportSender
Send crash report data. You don't have to take care of managing Threads, just implement what is necessary to handle the data. ACRA will use a specific Thread (not the UI Thread) to run your sender.

Specified by:
send in interface ReportSender
Parameters:
report - Stores key/value pairs for each report field. A report field is identified by a ReportField enum value.
Throws:
ReportSenderException - If anything goes fatally wrong during the handling of crash data, you can (should) throw a ReportSenderException with a custom message.


Copyright © 2010-2012. All Rights Reserved.