Question

I need to be able to schedule multiple Notifications at different times in the future.

I tried doing this with an AlarmManager, but that isn't suitable, for the following reason. From AlarmManager.set(): "If there is already an alarm for this Intent scheduled (with the equality of two intents being defined by filterEquals(Intent)), then it will be removed and replaced by this one."

Guess what, the sending intents are equal, apart from different Extra's (but those don't count for filterEquals).

So how can I schedule multiple notifications, which will still be shown when my application is killed (the whole reason I tried AlarmManager)?

Thanks.

Was it helpful?

Solution

Work out which event will occur first, schedule that, when your event fires have it schedule the next event to occur.

OTHER TIPS

I'm working on the same problem and decided not to use AlarmManager. The scheduled notifications worked fine in a test environment but in reality the users got the first couple of notifications and then it just stopped as if the alarms were cancelled.

I decided to make use of a service that runs every 15min and sends notifications for things that are overdue. This way the process at least gets started again if something happens to it where as if the alarm gets cancelled for some reason, it does not get recreated.

if you want to use multiple notification means..use different requestCode for different time notification

     notificationManager.notify(request_code_1,notification);
     notificationManager.notify(requestCode_2,notification);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top