Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.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
Android 使用GCMinentService中的URLDecoder.decode(字符串s,字符串)时出现空指针异常_Android_Nullpointerexception_Google Cloud Messaging_Urldecode - Fatal编程技术网

Android 使用GCMinentService中的URLDecoder.decode(字符串s,字符串)时出现空指针异常

Android 使用GCMinentService中的URLDecoder.decode(字符串s,字符串)时出现空指针异常,android,nullpointerexception,google-cloud-messaging,urldecode,Android,Nullpointerexception,Google Cloud Messaging,Urldecode,我使用代码gcminentservice.java对从GCM接收到的消息进行解码: String message = intent.getStringExtra("message"); // works fine. try { message = URLDecoder.decode(message, "UTF-8"); // decode fine, but get the error below. } catch (UnsupportedEncodingException e1) {

我使用代码gcminentservice.java对从GCM接收到的消息进行解码:

String message = intent.getStringExtra("message"); // works fine.
try {
     message = URLDecoder.decode(message, "UTF-8"); // decode fine, but get the error below.
} catch (UnsupportedEncodingException e1) {
throw new AssertionError("UTF-8 is unknown");
}
收到的信息与发送的信息相同。对于编码,我使用以下方法:

String message = URLEncoder.encode(items[0].getMessage(),"UTF-8"); // works fine
我得到这个错误,我找不到空指针异常的原因

07-19 17:33:44.687: E/AndroidRuntime(21742): FATAL EXCEPTION: IntentService[GCMIntentService-0002223333444-2]
07-19 17:33:44.687: E/AndroidRuntime(21742): java.lang.NullPointerException
07-19 17:33:44.687: E/AndroidRuntime(21742):    at com.chat.ak.GCMIntentService.onMessage(GCMIntentService.java:70)
07-19 17:33:44.687: E/AndroidRuntime(21742):    at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:223)
07-19 17:33:44.687: E/AndroidRuntime(21742):    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59)
07-19 17:33:44.687: E/AndroidRuntime(21742):    at android.os.Handler.dispatchMessage(Handler.java:99)
07-19 17:33:44.687: E/AndroidRuntime(21742):    at android.os.Looper.loop(Looper.java:130)
07-19 17:33:44.687: E/AndroidRuntime(21742):    at android.os.HandlerThread.run(HandlerThread.java:60)

非常感谢您。

第70行是哪一行?第70行是:message=URLDecoder.decodemessage.trim,UTF-8@user2600052您的第70行不是代码段的一部分,也没有被修改。这是我的代码片段的第三行。我尝试了带.trim和不带.trim的两行,得到了相同的错误。@user2600052您确定URLDecoder是导入的类java.net.URLDecoder而不是其他类吗?如果是这样,您可以尝试清理和重建整个项目