本文介绍了在BroadcastReceiver的扩展类使用getContentResolver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用getContentResolver方法在扩展的BroadcastReceiver类,我发现getContentResolver只能用于扩展活动的类。我尝试做一个扩展的活动类的静态方法,但我不能在静态方法中使用getContentResolver。我也试图与一个非静态方法,但是当我运行appliaction我得到一个错误。我能怎么做?谢谢!

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!

推荐答案

在你的的onReceive(上下文,意图)您会收到一个上下文对象,它有一个 getContentResolver()方法。

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

这篇关于在BroadcastReceiver的扩展类使用getContentResolver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 01:31