gpt4 book ai didi

java - ACRA 崩溃报告,将崩溃发送到多个电子邮件

转载 作者:行者123 更新时间:2023-11-29 20:20:21 24 4
gpt4 key购买 nike

我想将我的应用程序的 CrashReport 发送给多个收件人,这是否可能 无需 添加 ErrorReporter,只需在 @ReportCrashes?如果没有,可能的解决方案是什么?

代码:

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
)

提前致谢。 :)

最佳答案

你必须实现一个自己的发件人,像这样:

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

关于java - ACRA 崩溃报告,将崩溃发送到多个电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33289244/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com