Estoy creando una aplicación de cronómetro múltiple para la que habrá varios temporizadores que se ejecutarán en paralelo, y cada notificación enlazada a cada temporizador.Android: Administración de notificaciones múltiples en la barra de estado
Soy capaz de crear múltiples temporizadores con el siguiente código.
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);
}
El siguiente es el problema que estoy enfrentando. Considere que hay 3 temporizadores en ejecución y 3 notificaciones en la barra de estado. Cuando actualizo el temporizador 2, la notificación 3 (que está en el extremo derecho) se actualiza, pero lo que realmente quiero hacer es actualizar la segunda notificación (la del medio). Cuando imprimo las identificaciones de notificación, estoy viendo los valores correctos. No puedo entender por qué estoy recibiendo este comportamiento raro?
Lo probé, pero sigo teniendo el mismo problema –
En lugar de intent.setAction() utilicé intent.setData() y funcionó –