GCM の Android ドキュメントは、ここに記載されています
そのキー ペアの値が data パラメーターにある場合、それらはこのインテントでエクストラとして使用でき、キーはエクストラ名です。
private void handleMessage(Intent intent) {
// server sent 2 key-value pairs, score and time
String score = intent.getExtra("score");
String time = intent.getExtra("time");
// generates a system notification to display the score and time
}
しかし、intent.getExtra() メソッドは引数を受け入れません
public Bundle getExtras ()
Since: API Level 1
Retrieves a map of extended data from the intent.
Returns
the map of all extras previously added with putExtra(), or null if none have been added.
私の質問
メソッドでGCMメッセージから「文字列」を取得するonMessage()方法は?
PSonMessage(Context context, Intent intent): Called when your server sends a message to GCM, and GCM delivers it to the device. If the message has a payload, its contents are available as extras in the intent.