Search code examples
androidandroid-activitybroadcastreceiver

Using getContentResolver in BroadcastReceiver extended class


I have to use the getContentResolver method in a class that extends BroadcastReceiver and I found that getContentResolver can be used only in a class that extends Activity. I try to do a static method in a class that extends activity but i can't use getContentResolver in a static method. I also tried with a non-static method but when i run the appliaction I get an error. How can I do? Thanks!


Solution

  • In your onReceive(Context, Intent) you receive a Context object which has a getContentResolver() Method.