|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.acra.sender.HttpSender
public class HttpSender
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() { super.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)); } }
Nested Class Summary | |
---|---|
static class |
HttpSender.Method
Available HTTP methods to send data. |
static class |
HttpSender.Type
Type of report data encoding, currently supports Html Form encoding and JSON. |
Constructor Summary | |
---|---|
HttpSender(HttpSender.Method method,
HttpSender.Type type,
Map<ReportField,String> mapping)
Create a new HttpSender instance with its destination taken from ACRA.getConfig() dynamically. |
|
HttpSender(HttpSender.Method method,
HttpSender.Type type,
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 |
---|
public HttpSender(HttpSender.Method method, HttpSender.Type type, Map<ReportField,String> mapping)
Create a new HttpSender instance with its destination taken from
ACRA.getConfig()
dynamically. Configuration changes to the
formUri are applied automatically.
method
- HTTP HttpSender.Method
to be used to send data. Currently only
HttpSender.Method.POST
and HttpSender.Method.PUT
are available. If
HttpSender.Method.PUT
is used, the ReportField.REPORT_ID
is appended to the formUri to be compliant with RESTful APIs.type
- HttpSender.Type
of encoding used to send the report body.
HttpSender.Type.FORM
is a simple Key/Value pairs list as defined
by the application/x-www-form-urlencoded mime type.mapping
- Applies only to HttpSender.Method.POST
method parameter. 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);public HttpSender(HttpSender.Method method, HttpSender.Type type, 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.
method
- HTTP HttpSender.Method
to be used to send data. Currently only
HttpSender.Method.POST
and HttpSender.Method.PUT
are available. If
HttpSender.Method.PUT
is used, the ReportField.REPORT_ID
is appended to the formUri to be compliant with RESTful APIs.type
- HttpSender.Type
of encoding used to send the report body.
HttpSender.Type.FORM
is a simple Key/Value pairs list as defined
by the application/x-www-form-urlencoded mime type.formUri
- The URL of your server-side crash report collection script.mapping
- Applies only to HttpSender.Method.POST
method parameter. 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 |
---|
public void send(CrashReportData report) throws ReportSenderException
ReportSender
send
in interface ReportSender
report
- Stores key/value pairs for each report field. A report field
is identified by a ReportField
enum value.
ReportSenderException
- If anything goes fatally wrong during the handling of crash
data, you can (should) throw a ReportSenderException
with a custom message.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |