2015-10-22 129 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

謝謝,它正在工作 –