-2

我有每 12 小时触发一次的警报管理器,我在广播接收器中捕捉到它

@Override public void onReceive(final Context context, final Intent
bootintent) {
Intent anyService = new Intent(context, AnyService.class);
context.startService(anyService); }

所以,在那之后我想启动“AnyService”服务,我想为用户设置一些通知。我试图启动服务类。通知代码在哪里,但我有错误。我该如何解决?谢谢。

更新 :

05-11 08:58:30.776: D/AndroidRuntime(312): Shutting down VM
05-11 08:58:30.776: W/dalvikvm(312): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-11 08:58:30.795: E/AndroidRuntime(312): FATAL EXCEPTION: main
05-11 08:58:30.795: E/AndroidRuntime(312): java.lang.RuntimeException: Unable to start service com.poslovi.wolf.NotifyService@44ef9cd0 with Intent { cmp=com.poslovi.wolf/.NotifyService }: java.lang.NullPointerException
05-11 08:58:30.795: E/AndroidRuntime(312):  at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3063)
05-11 08:58:30.795: E/AndroidRuntime(312):  at android.app.ActivityThread.access$3600(ActivityThread.java:125)
05-11 08:58:30.795: E/AndroidRuntime(312):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2096)
05-11 08:58:30.795: E/AndroidRuntime(312):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 08:58:30.795: E/AndroidRuntime(312):  at android.os.Looper.loop(Looper.java:123)
05-11 08:58:30.795: E/AndroidRuntime(312):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-11 08:58:30.795: E/AndroidRuntime(312):  at java.lang.reflect.Method.invokeNative(Native Method)
05-11 08:58:30.795: E/AndroidRuntime(312):  at java.lang.reflect.Method.invoke(Method.java:521)
05-11 08:58:30.795: E/AndroidRuntime(312):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-11 08:58:30.795: E/AndroidRuntime(312):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-11 08:58:30.795: E/AndroidRuntime(312):  at dalvik.system.NativeStart.main(Native Method)
05-11 08:58:30.795: E/AndroidRuntime(312): Caused by: java.lang.NullPointerException
05-11 08:58:30.795: E/AndroidRuntime(312):  at com.poslovi.wolf.NotifyService.showNotification(NotifyService.java:48)
05-11 08:58:30.795: E/AndroidRuntime(312):  at com.poslovi.wolf.NotifyService.onStartCommand(NotifyService.java:26)
05-11 08:58:30.795: E/AndroidRuntime(312):  at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3053)
05-11 08:58:30.795: E/AndroidRuntime(312):  ... 10 more
05-11 08:58:38.845: D/AndroidRuntime(319): Shutting down VM
05-11 08:58:38.845: W/dalvikvm(319): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-11 08:58:38.856: E/AndroidRuntime(319): FATAL EXCEPTION: main
05-11 08:58:38.856: E/AndroidRuntime(319): java.lang.RuntimeException: Unable to start service com.poslovi.wolf.NotifyService@44ee4068 with Intent { cmp=com.poslovi.wolf/.NotifyService }: java.lang.NullPointerException
05-11 08:58:38.856: E/AndroidRuntime(319):  at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3063)
05-11 08:58:38.856: E/AndroidRuntime(319):  at android.app.ActivityThread.access$3600(ActivityThread.java:125)
05-11 08:58:38.856: E/AndroidRuntime(319):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2096)
05-11 08:58:38.856: E/AndroidRuntime(319):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 08:58:38.856: E/AndroidRuntime(319):  at android.os.Looper.loop(Looper.java:123)
05-11 08:58:38.856: E/AndroidRuntime(319):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-11 08:58:38.856: E/AndroidRuntime(319):  at java.lang.reflect.Method.invokeNative(Native Method)
05-11 08:58:38.856: E/AndroidRuntime(319):  at java.lang.reflect.Method.invoke(Method.java:521)
05-11 08:58:38.856: E/AndroidRuntime(319):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-11 08:58:38.856: E/AndroidRuntime(319):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-11 08:58:38.856: E/AndroidRuntime(319):  at dalvik.system.NativeStart.main(Native Method)
05-11 08:58:38.856: E/AndroidRuntime(319): Caused by: java.lang.NullPointerException
05-11 08:58:38.856: E/AndroidRuntime(319):  at com.poslovi.wolf.NotifyService.showNotification(NotifyService.java:48)
05-11 08:58:38.856: E/AndroidRuntime(319):  at com.poslovi.wolf.NotifyService.onStartCommand(NotifyService.java:26)
05-11 08:58:38.856: E/AndroidRuntime(319):  at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3053)
05-11 08:58:38.856: E/AndroidRuntime(319):  ... 10 more
05-11 09:00:27.406: D/AndroidRuntime(346): Shutting down VM
05-11 09:00:27.406: W/dalvikvm(346): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-11 09:00:27.426: E/AndroidRuntime(346): FATAL EXCEPTION: main
05-11 09:00:27.426: E/AndroidRuntime(346): java.lang.RuntimeException: Unable to create service com.poslovi.wolf.NotifyService: java.lang.NullPointerException
05-11 09:00:27.426: E/AndroidRuntime(346):  at android.app.ActivityThread.handleCreateService(ActivityThread.java:2969)
05-11 09:00:27.426: E/AndroidRuntime(346):  at android.app.ActivityThread.access$3300(ActivityThread.java:125)
05-11 09:00:27.426: E/AndroidRuntime(346):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2087)
05-11 09:00:27.426: E/AndroidRuntime(346):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 09:00:27.426: E/AndroidRuntime(346):  at android.os.Looper.loop(Looper.java:123)
05-11 09:00:27.426: E/AndroidRuntime(346):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-11 09:00:27.426: E/AndroidRuntime(346):  at java.lang.reflect.Method.invokeNative(Native Method)
05-11 09:00:27.426: E/AndroidRuntime(346):  at java.lang.reflect.Method.invoke(Method.java:521)
05-11 09:00:27.426: E/AndroidRuntime(346):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-11 09:00:27.426: E/AndroidRuntime(346):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-11 09:00:27.426: E/AndroidRuntime(346):  at dalvik.system.NativeStart.main(Native Method)
05-11 09:00:27.426: E/AndroidRuntime(346): Caused by: java.lang.NullPointerException
05-11 09:00:27.426: E/AndroidRuntime(346):  at com.poslovi.wolf.NotifyService.showNotification(NotifyService.java:46)
05-11 09:00:27.426: E/AndroidRuntime(346):  at com.poslovi.wolf.NotifyService.onCreate(NotifyService.java:18)
05-11 09:00:27.426: E/AndroidRuntime(346):  at android.app.ActivityThread.handleCreateService(ActivityThread.java:2959)
05-11 09:00:27.426: E/AndroidRuntime(346):  ... 10 more
05-11 09:00:35.735: D/AndroidRuntime(354): Shutting down VM
05-11 09:00:35.735: W/dalvikvm(354): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-11 09:00:35.765: E/AndroidRuntime(354): FATAL EXCEPTION: main
05-11 09:00:35.765: E/AndroidRuntime(354): java.lang.RuntimeException: Unable to create service com.poslovi.wolf.NotifyService: java.lang.NullPointerException
05-11 09:00:35.765: E/AndroidRuntime(354):  at android.app.ActivityThread.handleCreateService(ActivityThread.java:2969)
05-11 09:00:35.765: E/AndroidRuntime(354):  at android.app.ActivityThread.access$3300(ActivityThread.java:125)
05-11 09:00:35.765: E/AndroidRuntime(354):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2087)
05-11 09:00:35.765: E/AndroidRuntime(354):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 09:00:35.765: E/AndroidRuntime(354):  at android.os.Looper.loop(Looper.java:123)
05-11 09:00:35.765: E/AndroidRuntime(354):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-11 09:00:35.765: E/AndroidRuntime(354):  at java.lang.reflect.Method.invokeNative(Native Method)
05-11 09:00:35.765: E/AndroidRuntime(354):  at java.lang.reflect.Method.invoke(Method.java:521)
05-11 09:00:35.765: E/AndroidRuntime(354):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-11 09:00:35.765: E/AndroidRuntime(354):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-11 09:00:35.765: E/AndroidRuntime(354):  at dalvik.system.NativeStart.main(Native Method)
05-11 09:00:35.765: E/AndroidRuntime(354): Caused by: java.lang.NullPointerException
05-11 09:00:35.765: E/AndroidRuntime(354):  at com.poslovi.wolf.NotifyService.showNotification(NotifyService.java:46)
05-11 09:00:35.765: E/AndroidRuntime(354):  at com.poslovi.wolf.NotifyService.onCreate(NotifyService.java:18)
05-11 09:00:35.765: E/AndroidRuntime(354):  at android.app.ActivityThread.handleCreateService(ActivityThread.java:2959)
05-11 09:00:35.765: E/AndroidRuntime(354):  ... 10 more
05-11 09:08:27.977: D/AndroidRuntime(381): Shutting down VM
05-11 09:08:27.977: W/dalvikvm(381): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-11 09:08:27.995: E/AndroidRuntime(381): FATAL EXCEPTION: main
05-11 09:08:27.995: E/AndroidRuntime(381): java.lang.RuntimeException: Unable to start receiver com.poslovi.wolf.MyReceiver: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
05-11 09:08:27.995: E/AndroidRuntime(381):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2821)
05-11 09:08:27.995: E/AndroidRuntime(381):  at android.app.ActivityThread.access$3200(ActivityThread.java:125)
05-11 09:08:27.995: E/AndroidRuntime(381):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
05-11 09:08:27.995: E/AndroidRuntime(381):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 09:08:27.995: E/AndroidRuntime(381):  at android.os.Looper.loop(Looper.java:123)
05-11 09:08:27.995: E/AndroidRuntime(381):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-11 09:08:27.995: E/AndroidRuntime(381):  at java.lang.reflect.Method.invokeNative(Native Method)
05-11 09:08:27.995: E/AndroidRuntime(381):  at java.lang.reflect.Method.invoke(Method.java:521)
05-11 09:08:27.995: E/AndroidRuntime(381):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-11 09:08:27.995: E/AndroidRuntime(381):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-11 09:08:27.995: E/AndroidRuntime(381):  at dalvik.system.NativeStart.main(Native Method)
05-11 09:08:27.995: E/AndroidRuntime(381): Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
05-11 09:08:27.995: E/AndroidRuntime(381):  at android.app.ContextImpl.startActivity(ContextImpl.java:617)
05-11 09:08:27.995: E/AndroidRuntime(381):  at android.content.ContextWrapper.startActivity(ContextWrapper.java:258)
05-11 09:08:27.995: E/AndroidRuntime(381):  at android.content.ContextWrapper.startActivity(ContextWrapper.java:258)
05-11 09:08:27.995: E/AndroidRuntime(381):  at com.poslovi.wolf.MyReceiver.onReceive(MyReceiver.java:14)
05-11 09:08:27.995: E/AndroidRuntime(381):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2810)
05-11 09:08:27.995: E/AndroidRuntime(381):  ... 10 more
05-11 09:08:30.855: I/Process(381): Sending signal. PID: 381 SIG: 9
05-11 09:08:36.186: D/AndroidRuntime(389): Shutting down VM
05-11 09:08:36.186: W/dalvikvm(389): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-11 09:08:36.196: E/AndroidRuntime(389): FATAL EXCEPTION: main
05-11 09:08:36.196: E/AndroidRuntime(389): java.lang.RuntimeException: Unable to start receiver com.poslovi.wolf.MyReceiver: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
05-11 09:08:36.196: E/AndroidRuntime(389):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2821)
05-11 09:08:36.196: E/AndroidRuntime(389):  at android.app.ActivityThread.access$3200(ActivityThread.java:125)
05-11 09:08:36.196: E/AndroidRuntime(389):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
05-11 09:08:36.196: E/AndroidRuntime(389):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 09:08:36.196: E/AndroidRuntime(389):  at android.os.Looper.loop(Looper.java:123)
05-11 09:08:36.196: E/AndroidRuntime(389):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-11 09:08:36.196: E/AndroidRuntime(389):  at java.lang.reflect.Method.invokeNative(Native Method)
05-11 09:08:36.196: E/AndroidRuntime(389):  at java.lang.reflect.Method.invoke(Method.java:521)
05-11 09:08:36.196: E/AndroidRuntime(389):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-11 09:08:36.196: E/AndroidRuntime(389):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-11 09:08:36.196: E/AndroidRuntime(389):  at dalvik.system.NativeStart.main(Native Method)
05-11 09:08:36.196: E/AndroidRuntime(389): Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
05-11 09:08:36.196: E/AndroidRuntime(389):  at android.app.ContextImpl.startActivity(ContextImpl.java:617)
05-11 09:08:36.196: E/AndroidRuntime(389):  at android.content.ContextWrapper.startActivity(ContextWrapper.java:258)
05-11 09:08:36.196: E/AndroidRuntime(389):  at android.content.ContextWrapper.startActivity(ContextWrapper.java:258)
05-11 09:08:36.196: E/AndroidRuntime(389):  at com.poslovi.wolf.MyReceiver.onReceive(MyReceiver.java:14)
05-11 09:08:36.196: E/AndroidRuntime(389):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2810)
05-11 09:08:36.196: E/AndroidRuntime(389):  ... 10 more
05-11 09:09:52.255: D/AndroidRuntime(444): Shutting down VM
05-11 09:09:52.255: W/dalvikvm(444): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-11 09:09:52.265: E/AndroidRuntime(444): FATAL EXCEPTION: main
05-11 09:09:52.265: E/AndroidRuntime(444): java.lang.RuntimeException: Unable to start receiver com.poslovi.wolf.MyReceiver: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
05-11 09:09:52.265: E/AndroidRuntime(444):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2821)
05-11 09:09:52.265: E/AndroidRuntime(444):  at android.app.ActivityThread.access$3200(ActivityThread.java:125)
05-11 09:09:52.265: E/AndroidRuntime(444):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
05-11 09:09:52.265: E/AndroidRuntime(444):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 09:09:52.265: E/AndroidRuntime(444):  at android.os.Looper.loop(Looper.java:123)
05-11 09:09:52.265: E/AndroidRuntime(444):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-11 09:09:52.265: E/AndroidRuntime(444):  at java.lang.reflect.Method.invokeNative(Native Method)
05-11 09:09:52.265: E/AndroidRuntime(444):  at java.lang.reflect.Method.invoke(Method.java:521)
05-11 09:09:52.265: E/AndroidRuntime(444):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-11 09:09:52.265: E/AndroidRuntime(444):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-11 09:09:52.265: E/AndroidRuntime(444):  at dalvik.system.NativeStart.main(Native Method)
05-11 09:09:52.265: E/AndroidRuntime(444): Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
05-11 09:09:52.265: E/AndroidRuntime(444):  at android.app.ContextImpl.startActivity(ContextImpl.java:617)
05-11 09:09:52.265: E/AndroidRuntime(444):  at android.content.ContextWrapper.startActivity(ContextWrapper.java:258)
05-11 09:09:52.265: E/AndroidRuntime(444):  at android.content.ContextWrapper.startActivity(ContextWrapper.java:258)
05-11 09:09:52.265: E/AndroidRuntime(444):  at com.poslovi.wolf.MyReceiver.onReceive(MyReceiver.java:14)
05-11 09:09:52.265: E/AndroidRuntime(444):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2810)
05-11 09:09:52.265: E/AndroidRuntime(444):  ... 10 more
05-11 09:09:54.215: I/Process(444): Sending signal. PID: 444 SIG: 9
05-11 09:10:00.415: D/AndroidRuntime(452): Shutting down VM
05-11 09:10:00.415: W/dalvikvm(452): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-11 09:10:00.425: E/AndroidRuntime(452): FATAL EXCEPTION: main
05-11 09:10:00.425: E/AndroidRuntime(452): java.lang.RuntimeException: Unable to start receiver com.poslovi.wolf.MyReceiver: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
05-11 09:10:00.425: E/AndroidRuntime(452):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2821)
05-11 09:10:00.425: E/AndroidRuntime(452):  at android.app.ActivityThread.access$3200(ActivityThread.java:125)
05-11 09:10:00.425: E/AndroidRuntime(452):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
05-11 09:10:00.425: E/AndroidRuntime(452):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 09:10:00.425: E/AndroidRuntime(452):  at android.os.Looper.loop(Looper.java:123)
05-11 09:10:00.425: E/AndroidRuntime(452):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-11 09:10:00.425: E/AndroidRuntime(452):  at java.lang.reflect.Method.invokeNative(Native Method)
05-11 09:10:00.425: E/AndroidRuntime(452):  at java.lang.reflect.Method.invoke(Method.java:521)
05-11 09:10:00.425: E/AndroidRuntime(452):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-11 09:10:00.425: E/AndroidRuntime(452):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-11 09:10:00.425: E/AndroidRuntime(452):  at dalvik.system.NativeStart.main(Native Method)
05-11 09:10:00.425: E/AndroidRuntime(452): Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
05-11 09:10:00.425: E/AndroidRuntime(452):  at android.app.ContextImpl.startActivity(ContextImpl.java:617)
05-11 09:10:00.425: E/AndroidRuntime(452):  at android.content.ContextWrapper.startActivity(ContextWrapper.java:258)
05-11 09:10:00.425: E/AndroidRuntime(452):  at android.content.ContextWrapper.startActivity(ContextWrapper.java:258)
05-11 09:10:00.425: E/AndroidRuntime(452):  at com.poslovi.wolf.MyReceiver.onReceive(MyReceiver.java:14)
05-11 09:10:00.425: E/AndroidRuntime(452):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2810)
05-11 09:10:00.425: E/AndroidRuntime(452):  ... 10 more
05-11 09:13:26.635: D/AndroidRuntime(479): Shutting down VM
05-11 09:13:26.635: W/dalvikvm(479): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-11 09:13:26.646: E/AndroidRuntime(479): FATAL EXCEPTION: main
05-11 09:13:26.646: E/AndroidRuntime(479): java.lang.RuntimeException: Unable to start receiver com.poslovi.wolf.MyReceiver: java.lang.NullPointerException
05-11 09:13:26.646: E/AndroidRuntime(479):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2821)
05-11 09:13:26.646: E/AndroidRuntime(479):  at android.app.ActivityThread.access$3200(ActivityThread.java:125)
05-11 09:13:26.646: E/AndroidRuntime(479):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
05-11 09:13:26.646: E/AndroidRuntime(479):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 09:13:26.646: E/AndroidRuntime(479):  at android.os.Looper.loop(Looper.java:123)
05-11 09:13:26.646: E/AndroidRuntime(479):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-11 09:13:26.646: E/AndroidRuntime(479):  at java.lang.reflect.Method.invokeNative(Native Method)
05-11 09:13:26.646: E/AndroidRuntime(479):  at java.lang.reflect.Method.invoke(Method.java:521)
05-11 09:13:26.646: E/AndroidRuntime(479):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-11 09:13:26.646: E/AndroidRuntime(479):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-11 09:13:26.646: E/AndroidRuntime(479):  at dalvik.system.NativeStart.main(Native Method)
05-11 09:13:26.646: E/AndroidRuntime(479): Caused by: java.lang.NullPointerException
05-11 09:13:26.646: E/AndroidRuntime(479):  at android.widget.Toast.<init>(Toast.java:89)
05-11 09:13:26.646: E/AndroidRuntime(479):  at android.widget.Toast.makeText(Toast.java:231)
05-11 09:13:26.646: E/AndroidRuntime(479):  at com.poslovi.wolf.MyReceiver.showNotification(MyReceiver.java:28)
05-11 09:13:26.646: E/AndroidRuntime(479):  at com.poslovi.wolf.MyReceiver.onReceive(MyReceiver.java:24)
05-11 09:13:26.646: E/AndroidRuntime(479):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2810)
05-11 09:13:26.646: E/AndroidRuntime(479):  ... 10 more
05-11 09:13:29.425: I/Process(479): Sending signal. PID: 479 SIG: 9
05-11 09:13:34.845: D/AndroidRuntime(487): Shutting down VM
05-11 09:13:34.845: W/dalvikvm(487): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-11 09:13:34.855: E/AndroidRuntime(487): FATAL EXCEPTION: main
05-11 09:13:34.855: E/AndroidRuntime(487): java.lang.RuntimeException: Unable to start receiver com.poslovi.wolf.MyReceiver: java.lang.NullPointerException
05-11 09:13:34.855: E/AndroidRuntime(487):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2821)
05-11 09:13:34.855: E/AndroidRuntime(487):  at android.app.ActivityThread.access$3200(ActivityThread.java:125)
05-11 09:13:34.855: E/AndroidRuntime(487):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
05-11 09:13:34.855: E/AndroidRuntime(487):  at android.os.Handler.dispatchMessage(Handler.java:99)
4

1 回答 1

0

我在使用 tabHost 时遇到了这个问题。为了查找错误,我使用了“try-catch”,而 Exeption 让我发现我的第二类在我的 Manifest 中找不到。我写错了它的名字。我写了 '.list' 但我必须写 '.List' 。只是大写 :) 也许你应该控制你的清单

于 2012-05-24T19:49:03.327 回答