gpt4 book ai didi

java - 短信接收器仅在打开某个 Activity 时才起作用

转载 作者:行者123 更新时间:2023-11-30 03:24:23 26 4
gpt4 key购买 nike

我创建了一个应用程序,它使用 BroadcastReceiver 类在应用程序内接收 SMS 消息,以便在收到特定短信时更改和控制应用程序内的不同内容。我最近向应用程序添加了一个新 Activity ,现在的问题是,如果应用程序收到一条短信,它将崩溃,除非新 Activity 已经启动。谁能想到为什么会这样?谢谢

这是我的崩溃错误日志:

 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)

最佳答案

在主 Activity 的第 66 行有一个 nullPointerException

关于java - 短信接收器仅在打开某个 Activity 时才起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18511960/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com