I've got an for
block which looks like this:
for(int counter = 0; counter < sList.size(); counter++){
String s = sList.get(counter);
Notification notification = new NotificationCompat.Builder(this).setContentTitle("Title").setContentText(s).setSmallIcon(R.drawable.ic_launcher).setContentIntent(pendingIntent).build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(counter, notification);
}
This block is located in a service which is triggered by an alarmmanager. So this block may really well be executed a couple of times before the user sees the notifications. When this block is re-executed when something has been added to the sList, it overrides the current notifications, because the ID's of the notification are the same. How can I prevent that from happening? How can I get a unique ID every time? Or is there maybe possible to avoid the whole ID part, like telling android that is has to show the notification anyway, no matter what the ID is?
Thanks in advance!