Je crée une application de surveillance à arrêts multiples pour laquelle plusieurs temporisateurs sont exécutés en parallèle et chaque notification est liée à chaque temporisateur.Android: Gestion de plusieurs notifications dans la barre d'état
Je suis capable de créer plusieurs minuteurs avec le code suivant.
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.setClassName("com.intuit.time_catcher.android.activities",
"com.intuit.time_catcher.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);
}
Ce qui suit est le problème auquel je suis confronté. Considérer qu'il y a 3 temporisations en cours et 3 notifications dans la barre d'état. Quand je mets à jour le timer 2, la notification 3 (qui est à l'extrême droite) est mise à jour, mais ce que je veux vraiment faire est de mettre à jour la deuxième notification (celle du milieu). Lorsque j'imprime les identifiants de notification, je vois les bonnes valeurs. Je ne comprends pas pourquoi je reçois ce comportement bizarre?
Je l'ai essayé, mais je suis toujours confronté au même problème –
Au lieu d'intention.setAction() j'ai utilisé intention.setData() et cela a fonctionné –