1

I want to send the CrashReport of my app to multiple recipients, is this possible without adding a ErrorReporter, just in the @ReportCrashes? If not, what could be a possible solution?

Code:

import org.acra.ACRA;
import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes;

@ReportsCrashes(
    mailTo = "******@gmail.com",
    mode = ReportingInteractionMode.TOAST,
    resToastText = R.string.crash_toast_text
)

Thanks in advance. :)

Sebastian Schneider
  • 4,896
  • 3
  • 20
  • 47
  • 1
    Possible duplicate of [How to send ACRA reports to multiple destinations?](http://stackoverflow.com/questions/20901139/how-to-send-acra-reports-to-multiple-destinations) – Rami Oct 22 '15 at 19:36
  • I know it's not an answer to your question but there is a nice free library that does everything for you regarding crash reports, see crashlytics – Kirill Kulakov Oct 23 '15 at 08:16

2 Answers2

1

You have to implement a own sender, like this:

public class YourOwnSender implements ReportSender {

  private String emails[];
  private Context context;

  public YourOwnSender(Context context, String[] additionalEmails){
    this.email = additionalEmails;
    this.context = context;
  }

  @Override
  public void send(CrashReportData report) throws ReportSenderException {
    StringBuilder log = new StringBuilder();

    log.append("Package: " + report.get(ReportField.PACKAGE_NAME) + "\n");
    log.append("Version: " + report.get(ReportField.APP_VERSION_CODE) + "\n");
    log.append("Android: " + report.get(ReportField.ANDROID_VERSION) + "\n");
    log.append("Manufacturer: " + android.os.Build.MANUFACTURER + "\n");
    log.append("Model: " + report.get(ReportField.PHONE_MODEL) + "\n");
    log.append("Date: " + now + "\n");
    log.append("\n");
    log.append(report.get(ReportField.STACK_TRACE));

    String body = log.toString();
    String subject = mContext.getPackageName() + " Crash Report";

    for(int i=0; i<emails.length; i++) {
      final Intent emailIntent = new Intent(android.content.Intent.ACTION_SENDTO);
    emailIntent.setData(Uri.fromParts("mailto", ACRAgetConfig().mailTo(), null));
    emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);
    emailIntent.putExtra(android.content.Intent.EXTRA_BCC, emails);
    mContext.startActivity(emailIntent);
    }
  }
}
Ichor de Dionysos
  • 1,107
  • 1
  • 8
  • 30
1

The wording of your question suggests that you are looking to send to multiple email recipients. If that is the case then just comma separate them in the mailTo attribute. That is:

@ReportsCrashes(
    mailTo = "******@gmail.com, someOne@another.address",
    mode = ReportingInteractionMode.TOAST,
    resToastText = R.string.crash_toast_text
)

You don't need to configure another ReportSender for that use case.

William
  • 20,150
  • 8
  • 49
  • 91