J'essaie de créer plusieurs notifications dans mon application. Pour identifier chaque notification de manière unique, je leur ai donné un ID d'identification unique. À la suite de mon code:Android: Gestion de plusieurs notifications
private void updateNotification(int notificationId, int clockStatusID, CharSequence text) {
//notificationManager.cancel(notificationId);
// throws up an ongoing notification that the timer is running
Log.i("TIMERCOUNT", "Notification id: " + notificationId);
Notification not = new Notification(clockStatusID, // the
// icon
// for
// the
// status
// bar
text, // the text to display in the ticker
System.currentTimeMillis() // the timestamp for the
// notification to appear
);
Intent intent = new Intent();
intent.putExtra("notificationID", notificationId);
intent.setAction("actionstring" + System.currentTimeMillis());
intent.setClassName("com.chander.time.android.activities",
"com.chander.time.android.activities.Tabs");
not.setLatestEventInfo(self,
getText(R.string.timer_notification_title),
getText(R.string.timer_on_notification_text), PendingIntent
.getActivity(this, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT));
not.flags += Notification.FLAG_ONGOING_EVENT;
not.flags += Notification.FLAG_NO_CLEAR;
notificationManager.notify(notificationId, not);
}
Problème: Lorsqu'une notification est sélectionnée, l'activité est appelée onglets passer l'intention. Je souhaite accéder à l'unique notificationId de la notification sélectionnée dans les onglets. J'ai essayé intention.putExtra() pour enregistrer le notificationId dans l'intention. Mais, pour les notifications multiples, il écrase le notificationId et renvoie le dernier. Je ne comprends pas pourquoi cela se produit et comment puis-je éviter cet écrasement de notificationId.
Merci, Chander