我有一个主要课程,即
Class A extends BroadcastReceiver {
ClassB hello = new ClassB
Public void onReceive(){
// Value obtained from Method in Class B
String Message = hello.2ndFunction()
}
Class B extends Activity{
public String 2ndFunction(){
// 2ndFunction Lines......
}
}
}
这是我的场景。但我得到了错误
06-20 09:17:02.584: E/AndroidRuntime(1076): FATAL EXCEPTION: main
06-20 09:17:02.584: E/AndroidRuntime(1076): java.lang.RuntimeException: Unable to start receiver com.example.timesheetcalculator.ReceiveSMS: java.lang.NullPointerException
06-20 09:17:02.584: E/AndroidRuntime(1076): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2383)
06-20 09:17:02.584: E/AndroidRuntime(1076): at android.app.ActivityThread.access$1500(ActivityThread.java:141)
06-20 09:17:02.584: E/AndroidRuntime(1076): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1310)
06-20 09:17:02.584: E/AndroidRuntime(1076): at android.os.Handler.dispatchMessage(Handler.java:99)
06-20 09:17:02.584: E/AndroidRuntime(1076): at android.os.Looper.loop(Looper.java:137)
06-20 09:17:02.584: E/AndroidRuntime(1076): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-20 09:17:02.584: E/AndroidRuntime(1076): at java.lang.reflect.Method.invokeNative(Native Method)
06-20 09:17:02.584: E/AndroidRuntime(1076): at java.lang.reflect.Method.invoke(Method.java:511)
06-20 09:17:02.584: E/AndroidRuntime(1076): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-20 09:17:02.584: E/AndroidRuntime(1076): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-20 09:17:02.584: E/AndroidRuntime(1076): at dalvik.system.NativeStart.main(Native Method)
06-20 09:17:02.584: E/AndroidRuntime(1076): Caused by: java.lang.NullPointerException
06-20 09:17:02.584: E/AndroidRuntime(1076): at android.content.ContextWrapper.getContentResolver(ContextWrapper.java:99)
06-20 09:17:02.584: E/AndroidRuntime(1076): at com.example.timesheetcalculator.ReceiveSMS$CallLogsExtracter.CallLogs(ReceiveSMS.java:75)
06-20 09:17:02.584: E/AndroidRuntime(1076): at com.example.timesheetcalculator.ReceiveSMS.onReceive(ReceiveSMS.java:47)
06-20 09:17:02.584: E/AndroidRuntime(1076): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2376)
可能是什么问题呢 ?