我一直在尝试从收到的 GCM 消息中提取信息。这是从我的服务器发送的消息:
"Message(data: {profile={"id":"214","name":"Dr Who","phone_number":"214"}})"
并在手机上收到的消息:
05-24 21:00:26.083: D/GCMIntentServiceReceived Message:(3929): Received Message: Message(data: {profile={"id":"214","name":"Dr Who","phone_number":"214"}})
这是我用来尝试提取键/值对的代码。
@Override
protected void onMessage(Context arg0, Intent intent) {
String message = intent.getStringExtra("message");
JsonParser parser = new JsonParser();
JSONFingerprint fingerprintProfile = null;
Log.d(TAG + "Received Message: ", "Received Message: " + message.toString());
//System.out.println("PHONE " + intent.getExtras().getString("id")); This returns null
}
我试图在这个例子中提取“id”字段,但我总是得到 NULL。有人有什么想法吗?谢谢!