0

我有这样的类结构:

public class DHTContentProvider extends ContentProvider {
    private Networking networking = new Networking();
    public boolean onCreate() {
         networking.init();
    }
    public class Networking extends Service {
         public void init() {
              TelephonyManager tel = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); 
         }
    }
}

Networking 是 DHTContentProvider 的子类。当我运行它时总是 NullPointerException。有人有想法吗?

4

2 回答 2

0

也许您应该删除它们“上下文”。

于 2012-04-12T01:34:17.923 回答
0

调用getContext()以检索 a Context,然后调用getSystemService()该上下文。

于 2012-04-12T00:14:02.197 回答