3

I followed the instructions on setting up the ACRA to send the emails using-

Sending Reports By Email

However can't figured out how to silently send the email to the developer on crash without any email client to choose by the user.

 @ReportsCrashes(formKey = "",  mailTo = "myemail@xyz.com",
        customReportContent = { ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL, ReportField.CUSTOM_DATA,
 ReportField.STACK_TRACE, ReportField.LOGCAT },
        logcatArguments = { "-t", "200", "-v", "long","test:I" ,"*:D","*:S"},        
        mode = ReportingInteractionMode.SILENT,
        reportType=Type.JSON)

With the above setting, I am still getting the default email client to choose from in order to send the crash report.

How to do it directly ?

NullPointerException
  • 3,978
  • 4
  • 34
  • 52
sjain
  • 23,126
  • 28
  • 107
  • 185

4 Answers4

2

You can't. The Android framework doesn't allow it.

William
  • 20,150
  • 8
  • 49
  • 91
  • OK. Then what's the line `mode = ReportingInteractionMode.SILENT` referring to ? – sjain Mar 19 '14 at 05:49
  • 1
    ReportingInteractionMode.SILENT implies you are sending via HTTP using either the formUri or formKey. It is ignored if you specify the mailTo property as sending email requires explicit action from a user. That's just part of the Android framework. – William Mar 20 '14 at 01:06
1

You can do it via HTTP, if you implemented your own mail service only you need to do this:

create a new class:

public class MyCrashSender implements ReportSender {
  @Override
  public void send(CrashReportData report) throws ReportSenderException {
    // make your http post
    // e.g. final HttpPost httpPost = new HttpPost(MY_service_url);
    .
    .
    .
    //httpClient.execute(httpPost);
  }
}

And then in your activity or you Application when you init acra...

ACRA.init(this);
MyCrashSender crashSender = new MyCrashSender();
ACRA.getErrorReporter().setReportSender(crashSender);

You can attach to http post the primary email of the device.

Pablo Pantaleon
  • 1,506
  • 1
  • 19
  • 38
1

If you just want silent reporting, e-mail is not necessarily the best option. I would recommend to use any backend crash collection service, for example, HockeyApp.

By using it, not only do you get e-mail notifications (alerts which HockeyApp sends to your mailbox) but also a handy crash reports bookkeeping (which includes reports grouping, ticket creation in your bug tracker, etc.)

This library helped me a lot to integrate ACRA and HockeyApp: https://github.com/antoche/android-debug.

Alex Dmitriev
  • 3,664
  • 3
  • 29
  • 35
1

You will have it implement your own ReportSender.
And this ReportSender implementation can silently email the crash report using the java mail api.
This post details it : http://androidcocktail.blogspot.in/2015/05/silentemail-crash-report-using-acra.html

Neeraj
  • 2,376
  • 2
  • 24
  • 41