Only one alarm fired when multiple ones are set

My goal is to fire an alarm for every event from eventsDb.getFavouriteEvents() but only one is fired everytime.

In my opinion, it may be caused by setting PendingIntent.FLAG_UPDATE_CURRENT, however I need this flag to post Extras with an intent. Is there any way not to set this flag and still post Extras with the intent?

I'm storing PendinIntents in a Collection (pendingIntents) because I'm canceling them in onDestroy() of this Service class.

This is code from onCreate():

for(Event event : eventsDB.getFavouriteEvents()) {
  Intent intent = new Intent(AlarmReciever.ONCOMING_EVENT);
  intent.putExtra(Event.TITLE, event.getTitle());

  PendingIntent pendingIntent = PendingIntent.getBroadcast(EventAlarmService.this, 0, intent, 
    Intent.FLAG_GRANT_READ_URI_PERMISSION | PendingIntent.FLAG_UPDATE_CURRENT);
  alarmManager.set(AlarmManager.RTC_WAKEUP, event.getTime(), pendingIntent);

  pendingIntents.add(pendingIntent);
}

Thanks for help!

Answers


The PendingIntent will be overwritten on send if they share the same code. Changing the code for each intent on send should correct this problem.


Need Your Help

PartialViews - Not Using Shared Site.css in Editor/Display Templates - ASP.NET MVC 3

html css asp.net-mvc-3 razor partial-views

I'm using the JQuery UI Tabs functionality in my Open Source Project. I'm doing this to learn MVC3 (And various other technologies). Now I've got that all working. The problem is my Partial Views w...

A curiosity about the VS2010 text editor

c++ visual-studio-2010 visual-c++ intellisense

Given the A.h file below (note that on purpose, I didn't include the <iostream> header in this file). The VS2010 text editor then shows a red line below std, as it doesn't recognize this name...