我的錯誤定位了,但是我不知道怎麼改,請大神指點哈。
代碼如下
switch (bundle.getInt(PushConsts.CMD_ACTION)) {
case PushConsts.GET_CLIENTID:
comm_frame.dev.client_id = bundle.getString("clientid"); <--這裡
}
錯誤原因是comm_frame.dev.client_id聲明了但是未初始化,但是我更改成
comm_frame.dev.client_id = null;
comm_frame.dev.client_id = bundle.getString("clientid");
還是報錯,我應該怎麼改它才能正常工作呢,請求指點。
錯誤信息如下
07-09 19:53:49.434 30483-30483/ixz.fish_help_app E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start receiver comm.GetuiReceiver: java.lang.NullPointerException
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2287)
at android.app.ActivityThread.access$1600(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4935)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at comm.GetuiReceiver.onReceive(GetuiReceiver.java:140)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2280)
at android.app.ActivityThread.access$1600(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4935)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
comm_frame.dev.client_id中comm_frame有沒有初始化,報的是空指針。所以看
comm_frame這個對象和bundle是不是空值就行了