Android notification scheduling

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

I tried to do this using AlarmManager, but this does not work for the following reason. From AlarmManager.set (): "If there is already an alarm for this planned intention (if two intentions defined by filterEquals (Intent) are equal), it will be deleted and replaced with this."

Guess that, the starting intentions are equal, except for different Extra (but they do not take into account filterEquals).

So, how can I schedule several notifications to be displayed when my application is killed (all the reason I tried AlarmManager)?

Thanks.

+4
source share
3 answers

Determine which event will occur first, plan when the next event will be scheduled when your event fires.

+4
source

I am working on the same issue and decided not to use AlarmManager. Scheduled notifications worked fine in a test environment, but in fact, users received the first few notifications, and then just stopped, as if the alarms had been canceled.

I decided to use a service that runs every 15 minutes and sends out notifications of expired things. Thus, the process, at least, starts again, if something happens to it, when for some reason the alarm is canceled, it is not recreated.

+3
source

if you want to use several means of notification. Use a different request code for different time notifications

notificationManager.notify(request_code_1,notification); notificationManager.notify(requestCode_2,notification); 
+1
source

Source: https://habr.com/ru/post/1305648/


All Articles