4
Android文档here状态的Android GCM - 为GCM“处理接收到的数据”
该密钥对数据中的值参数,它们可在此意图 群众演员,用钥匙是多余的名字。
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.
MyQuestion
如何从GCM消息onMessage()
方法检索 '字符串'?
P.S onMessage(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.
+1,为什么你指示我走向捆绑。你的答案是否来自可信来源? – 2012-07-28 22:29:40
因为getExtras()为您提供了一个Bundle。 – thomasg 2012-07-30 16:16:40