在向自托管服务器发送报告时,使用ACRA for Android可配置的URL?

Joe*_*oel 6 android

我正在使用ACRA for Android,我想将崩溃报告发送到我自己的服务器.我把它设置得很好,一切正常.但是,我想将报告发送的URL设置为可配置.但我不知道该怎么做.

这是我用来设置URL的代码

    @ReportsCrashes(formKey = "", // will not be used
            formUri = "http://yourserver.com/yourscript",
            formUriBasicAuthLogin = "yourlogin", // optional
            formUriBasicAuthPassword = "y0uRpa$$w0rd", // optional
            mode = ReportingInteractionMode.TOAST,
            resToastText = R.string.crash_toast_text)
    public class MyApplication extends Application {
    ...
Run Code Online (Sandbox Code Playgroud)

所以基本上,我不能formUri在应用程序中进行配置.可能吗?

ben*_*nvd 9

似乎现在不推荐使用ErrorReporter.getInstance,但以下行具有相同的效果.在调用ACRA.init之前执行它们.

ACRAConfiguration config = ACRA.getConfig();
config.setFormUri("http://server.com/script");
ACRA.setConfig(config);
Run Code Online (Sandbox Code Playgroud)


Joe*_*oel 3

也许我发布问题有点快,因为我自己找到了如何做到这一点...但是可以使用以下代码行更改 URL:

    ErrorReporter.getInstance().setReportSender(new HttpPostSender(newAddress, null));
Run Code Online (Sandbox Code Playgroud)

编辑:旧答案,请参阅bendvds更新的答案