我期待在this code in the Android documentation堆疊通知:如何實現堆疊通知
mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// Sets an ID for the notification, so it can be updated
int notifyID = 1;
mNotifyBuilder = new NotificationCompat.Builder(this)
.setContentTitle("New Message")
.setContentText("You've received new messages.")
.setSmallIcon(R.drawable.ic_notify_status)
numMessages = 0;
// Start of a loop that processes data and then notifies the user
...
mNotifyBuilder.setContentText(currentText)
.setNumber(++numMessages);
// Because the ID remains unchanged, the existing notification is
// updated.
mNotificationManager.notify(
notifyID,
mNotifyBuilder.build());
...
,但我不明白你如何保持跨越多個收據從GCM軌道numMessages
參數或如何開始正如他們在評論中所說的那樣,一個「處理數據的循環」。我想你會需要檢索任何當前通知,然後將新數據附加到它們。任何幫助讚賞。
編輯:我也不明白,如果每個通知都覆蓋最後一個,爲什麼不直接發送一個通知給最後一次迭代呢?
您是否解決了您的問題?如果是這樣,怎麼樣?我想知道同樣的事情。 –