Search code examples
androidandroid-contextacra

Get android context inside Acra reportSender implementation


Is there a way to get android context inside custom ACRA ReportSender implementation class?

public class MyReportSender implements ReportSender {
    public ErrorReportSender(){}
}

Solution

  • You can save reference to object of your Application implementation into the static variable and get it using static method:

        private static Application sInstance;
    
    @Override
    public void onCreate ()
    {
        sInstance = this;
        ACRA.init( this );
        super.onCreate();
    }
    public static Application getInstance()
    {
      return sInstance;
    }