Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.lang.RuntimeException:无法启动receiver*.mycustomReceiver java.lang.NullPointerException_Java_Android - Fatal编程技术网

java.lang.RuntimeException:无法启动receiver*.mycustomReceiver java.lang.NullPointerException

java.lang.RuntimeException:无法启动receiver*.mycustomReceiver java.lang.NullPointerException,java,android,Java,Android,我收到一个Java空指针异常无法启动接收器错误。我正在制作一个从parse.com接收推送的应用程序,我得到了安卓4.0.3-4.0.4的错误,并且在我重新启动一些设备时 我的日志是 **java.lang.RuntimeException: Unable to start receiver com.omega.omegaplus.main.MyCustomReceiver: java.lang.NullPointerException at android.app.ActivityThread

我收到一个Java空指针异常无法启动接收器错误。我正在制作一个从parse.com接收推送的应用程序,我得到了安卓4.0.3-4.0.4的错误,并且在我重新启动一些设备时

我的日志是

**java.lang.RuntimeException: Unable to start receiver com.omega.omegaplus.main.MyCustomReceiver: java.lang.NullPointerException
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2419)
at android.app.ActivityThread.access$1500(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1322)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:4987)
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:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116)
at org.json.JSONTokener.nextValue(JSONTokener.java:94)
at org.json.JSONObject.<init>(JSONObject.java:154)
at org.json.JSONObject.<init>(JSONObject.java:171)
at com.omega.omegaplus.main.MyCustomReceiver.onReceive(MyCustomReceiver.java:30)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2408)
... 10 more**

当我重新启动手机时,它也会显示相同的错误…,否则它工作正常。

我会猜测
消息
的值为
NULL

    JSONObject jObject;
    try {
        if (message != null && !message.equals("") {
          jObject = new JSONObject(message);
          //objectId = jObject.getString("id");
          time = jObject.getString("time");
          msg = jObject.getString("title");
          title = jObject.getString("msg");
          GCMMessage gcmMessage = new GCMMessage();

          //gcmMessage.setMsg_id(1);
          gcmMessage.setMsg_body(msg);
          gcmMessage.setMsg_title(title);
          gcmMessage.setType(0);
          gcmMessage.setDateTime(time);

          DatabaseUtil.insertMessage(context, gcmMessage);
        }

      }        
      catch (JSONException e) {
        e.printStackTrace();
      }

30号线在哪?这就是你的空指针异常发生的地方。我看不出你得到错误的代码段。哪段代码指向com.omega.omegaplus.main.MyCustomReceiver.onReceive(MyCustomReceiver.java:30)上的这个位置?消息的价值是什么?它不包括在您的logcat输出中,可能是消息接受值
,因此jObject为空,因此尝试从
jObject
获取任何内容都不会给出任何结果,但此错误仅发生在HTC Desire V(primods)上这并没有提供问题的答案。若要评论或要求作者澄清,请在其帖子下方留下评论。RiggsFolly-不同意。鉴于信息,我强烈怀疑我的答案是正确的。无论如何,我用一些代码更新了答案。
    JSONObject jObject;
    try {
        if (message != null && !message.equals("") {
          jObject = new JSONObject(message);
          //objectId = jObject.getString("id");
          time = jObject.getString("time");
          msg = jObject.getString("title");
          title = jObject.getString("msg");
          GCMMessage gcmMessage = new GCMMessage();

          //gcmMessage.setMsg_id(1);
          gcmMessage.setMsg_body(msg);
          gcmMessage.setMsg_title(title);
          gcmMessage.setType(0);
          gcmMessage.setDateTime(time);

          DatabaseUtil.insertMessage(context, gcmMessage);
        }

      }        
      catch (JSONException e) {
        e.printStackTrace();
      }