Reputation: 5532
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. :)
Upvotes: 1
Views: 815
Reputation: 20196
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, [email protected]",
mode = ReportingInteractionMode.TOAST,
resToastText = R.string.crash_toast_text
)
You don't need to configure another ReportSender
for that use case.
Upvotes: 1
Reputation: 1137
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);
}
}
}
Upvotes: 1