【IntentService】 IntentService onHandleIntent 空指针

今天本打算写一个IntentService的小例子,但是报错了。

04-03 18:19:53.849: W/dalvikvm(12857): threadid=1: thread exiting with uncaught exception (group=0x40015568)
04-03 18:19:53.849: E/AndroidRuntime(12857): FATAL EXCEPTION: main
04-03 18:19:53.849: E/AndroidRuntime(12857): java.lang.RuntimeException: Unable to start service com.paad.services.MyIntentService@4050f420 with Intent { cmp=com.paad.services/.MyIntentService }: java.lang.NullPointerException
04-03 18:19:53.849: E/AndroidRuntime(12857): 	at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2069)
04-03 18:19:53.849: E/AndroidRuntime(12857): 	at android.app.ActivityThread.access$2800(ActivityThread.java:117)
04-03 18:19:53.849: E/AndroidRuntime(12857): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:994)
04-03 18:19:53.849: E/AndroidRuntime(12857): 	at android.os.Handler.dispatchMessage(Handler.java:99)
04-03 18:19:53.849: E/AndroidRuntime(12857): 	at android.os.Looper.loop(Looper.java:130)
04-03 18:19:53.849: E/AndroidRuntime(12857): 	at android.app.ActivityThread.main(ActivityThread.java:3703)
04-03 18:19:53.849: E/AndroidRuntime(12857): 	at java.lang.reflect.Method.invokeNative(Native Method)
04-03 18:19:53.849: E/AndroidRuntime(12857): 	at java.lang.reflect.Method.invoke(Method.java:507)
04-03 18:19:53.849: E/AndroidRuntime(12857): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
04-03 18:19:53.849: E/AndroidRuntime(12857): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
04-03 18:19:53.849: E/AndroidRuntime(12857): 	at dalvik.system.NativeStart.main(Native Method)
04-03 18:19:53.849: E/AndroidRuntime(12857): Caused by: java.lang.NullPointerException
04-03 18:19:53.849: E/AndroidRuntime(12857): 	at android.app.IntentService.onStart(IntentService.java:110)
04-03 18:19:53.849: E/AndroidRuntime(12857): 	at android.app.IntentService.onStartCommand(IntentService.java:118)
04-03 18:19:53.849: E/AndroidRuntime(12857): 	at com.paad.services.MyIntentService.onStartCommand(MyIntentService.java:30)
04-03 18:19:53.849: E/AndroidRuntime(12857): 	at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2056)
04-03 18:19:53.849: E/AndroidRuntime(12857): 	... 10 more

各种查资料,后来在StackOverFlow上面找到了答案。

http://stackoverflow.com/questions/7165215/null-pointer-exception-starting-intentservice

原来在onCreate里面没有调用super.onCreate。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值