如何使用自定义实施 ACRA URL

How to implement ACRA with custom URL

  1. 我想在后台发送崩溃报告的邮件,但无法发送,因为它正在使用ACTION_SEND 我正在使用代码:formKey = "", mailTo = "abc@gmail.com"

  2. 如何使 url 可以将报告保存到我自己的服务器,如果有任何虚拟 url 可用于存储或可以使用任何开源数据库.请推荐

谢谢

使用这个习惯class:

public class AcraCustomSender implements ReportSender {

    Context activity;

    @Override
    public void send(Context context, CrashReportData errorContent) throws ReportSenderException {
        activity=context;
        String crashReport = "";

        try {
            JSONObject object =  errorContent.toJSON();
            Log.e("acra", object.toString());
            crashReport = object.toString();


        }catch (JSONReportBuilder.JSONReportException e) {
            e.printStackTrace();
        }

        //the string crashreport contains your crash log. you can pass it to your own backend.

    }
}

为您的应用创建另一个 class:

public class YourApplication extends Application {

    @Override
    public void onCreate() {
        try {
            ACRA.init(this);
            AcraCustomSender yourSender = new AcraCustomSender();
            ACRA.getErrorReporter().setReportSender(yourSender);
            super.onCreate();
        }catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

现在,每当应用程序崩溃时,您都可以在 AcraCustomSender class 中获取它,然后做任何您想做的事情(比如发送到您自己的数据库)