检索GCM消息Intent的“内容”。

时间:2013-02-22 09:49:17

标签: android android-intent push-notification google-cloud-messaging

这是从服务器发送消息的方式:

        //Queue Android GCM Notification
        _pushService.QueueNotification(NotificationFactory.AndroidGcm()
            .ForDeviceRegistrationId(device)
            .WithCollapseKey("LATEST")
            .WithJson("{\"alert\":\"" + message + "\",\"badge\":\"7\"}"));

我收到了意图,如何收到消息?我试过了:

    Log.d(TAG, "" + intent.getStringExtra("{\"alert\":\""));
    Log.d(TAG, "" + intent.getStringExtra("LATEST"));
    Log.d(TAG, "" + intent.getStringExtra("data"));

所有都为空,是否为消息文本值的键?

1 个答案:

答案 0 :(得分:3)

知道了,

Bundle b = intent.getExtras();
Set<String> allThatsInThere = b.keySet();