2015-10-22 133 views
1

我想我的应用程序的CrashReport发送给多个收件人,这可能没有添加ErrorReporter,只是在@ReportCrashes? 如果不是,可能的解决方案是什么?ACRA崩溃报告,发送到崩溃多封电子邮件

代码:

在此先感谢。 :)

+1

[如何将ACRA报告发送到多个目的地?](http://stackoverflow.com/questions/20901139/how-to-send-acra-reports-to-multiple-destinations) – Rami

+0

我知道它是不是你的问题的答案,但有一个很好的免费图书馆,为您做一切有关崩溃报告,请参阅crashlytics –

回答

1

您必须实现自己的发件人,就像这样:

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); 
    } 
    } 
} 
1

你的问题的措辞表明,你正在寻找发送给多个电子邮件收件人。如果是这种情况,那么只需用逗号将它们分在mailTo属性中。即:

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

您不需要为该用例配置另一个ReportSender

+0

谢谢,它正在工作 –