Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send email on application crash in silent mode using ACRA

Tags:

android

acra

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 = "[email protected]",
        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 ?

like image 893
My God Avatar asked Jan 01 '26 12:01

My God


2 Answers

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

like image 126
William Avatar answered Jan 03 '26 11:01

William


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.

like image 20
Pablo Pantaleon Avatar answered Jan 03 '26 10:01

Pablo Pantaleon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!