我创建了一个应用程序,它使用 BroadcastReceiver 类在应用程序内接收 SMS 消息,以在收到特定文本消息时更改和控制应用程序内的不同内容。我最近向应用程序添加了一个新活动,现在的问题是如果应用程序收到一条 SMS 消息,除非新活动已启动,否则它将崩溃。谁能想到这可能是为什么?谢谢
这是我的崩溃错误日志:
07-31 15:51:50.135: E/AndroidRuntime(779): FATAL EXCEPTION: main
07-31 15:51:50.135: E/AndroidRuntime(779): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.becatech.gsmzonecontroller/com.becatech.gsmzonecontroller.MainActivity}: java.lang.NullPointerException
07-31 15:51:50.135: E/AndroidRuntime(779): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
07-31 15:51:50.135: E/AndroidRuntime(779): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
07-31 15:51:50.135: E/AndroidRuntime(779): at android.app.ActivityThread.access$700(ActivityThread.java:140)
07-31 15:51:50.135: E/AndroidRuntime(779): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
07-31 15:51:50.135: E/AndroidRuntime(779): at android.os.Handler.dispatchMessage(Handler.java:99)
07-31 15:51:50.135: E/AndroidRuntime(779): at android.os.Looper.loop(Looper.java:137)
07-31 15:51:50.135: E/AndroidRuntime(779): at android.app.ActivityThread.main(ActivityThread.java:4921)
07-31 15:51:50.135: E/AndroidRuntime(779): at java.lang.reflect.Method.invokeNative(Native Method)
07-31 15:51:50.135: E/AndroidRuntime(779): at java.lang.reflect.Method.invoke(Method.java:511)
07-31 15:51:50.135: E/AndroidRuntime(779): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
07-31 15:51:50.135: E/AndroidRuntime(779): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
07-31 15:51:50.135: E/AndroidRuntime(779): at dalvik.system.NativeStart.main(Native Method)
07-31 15:51:50.135: E/AndroidRuntime(779): Caused by: java.lang.NullPointerException
07-31 15:51:50.135: E/AndroidRuntime(779): at com.becatech.gsmzonecontroller.MainActivity.onCreate(MainActivity.java:66)
07-31 15:51:50.135: E/AndroidRuntime(779): at android.app.Activity.performCreate(Activity.java:5206)
07-31 15:51:50.135: E/AndroidRuntime(779): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
07-31 15:51:50.135: E/AndroidRuntime(779): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)