2

I have times like 9:00 AM, 1:00 PM, 7:00 PM, where I set 3 pending intents that are recursively triggered using setRepeating() method every day.

(Here I am saving all these pending intents unique request codes in the local SQLite database)

Here, whenever an alarm is triggered I would like to know the next alarm that is going to be triggered and show to user

Example.. Now an alarm was triggered at 9:00 AM and at this time I should display the user that the next alarm is going to be triggered at 1:00 PM. Is there any solution that I could get the next alarm details.

Hope I conveyed correctly.If any queries please let me know

Thanks in Advance!

sudha
  • 193
  • 13
  • AlarmManager has a method called getNextAlarmClock(). Did you try that? – Saran Sankaran Dec 18 '17 at 07:21
  • " Gets information about the next alarm clock currently scheduled. The alarm clocks considered are those scheduled by any application using the setAlarmClock(AlarmManager.AlarmClockInfo, PendingIntent) method. "----this was mentioned in developer.android.com whereas I am setting alarms using alarmmanager.setRepeating method – sudha Dec 18 '17 at 07:27
  • I don't think you will be able to get the next scheduled alarm in any way. What I feel is that you will have to handle them manually. – Saran Sankaran Dec 18 '17 at 07:39

1 Answers1

0

As I said in the other question, you cannot get this information from the AlarmManager. You would need to store the information yourself in a SharedPreferences so that you can refer to it later.

For example, whenever your alarm goes off, you can update the SharedPreferences to indicate when the next repeat should happen.

David Wasser
  • 93,459
  • 16
  • 209
  • 274