Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configurable URL with ACRA for Android when sending report to self hosted server?

Tags:

android

I'm using ACRA for Android, and I want to send the crash reports to my own server. I've set it up alright, and everything works fine. However, I would like to make the URL that the reports are sent to configurable. But I do not know how to do it.

Here is the code I use to set the 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 {
    ...

So basically, I wan't to be able to configure formUri from within the application. Is it possible?

like image 299
Joel Avatar asked Oct 28 '11 14:10

Joel


2 Answers

It seems ErrorReporter.getInstance is now deprecated, but the following lines have the same effect. Execute them before calling ACRA.init.

ACRAConfiguration config = ACRA.getConfig();
config.setFormUri("http://server.com/script");
ACRA.setConfig(config);
like image 165
benvd Avatar answered Nov 15 '22 07:11

benvd


Maybe I was a bit quick to post a question, because I found how to do it by myself... But the URL can be changed with the following line of code:

    ErrorReporter.getInstance().setReportSender(new HttpPostSender(newAddress, null));

Edit: Old answer, see bendvds updated answer

like image 22
Joel Avatar answered Nov 15 '22 06:11

Joel