2

I used setRepeating() for repeating alarms as per my app requirement. Here, I would also like to know the next alarm that was set using setRepeating() .whereas I couldn't find any of the solutions that give me next alarm time using an alarm that was set with setRepeating(). Even I posted the same question but I got to know that we cant get.(Link here -->) how to know next alarm time using setRepeating() method.

whereas somewhere I found we can get next alarm details using setAlarmClock -

alarmManager.setAlarmClock(new AlarmManager.AlarmClockInfo(date.getTime(),pendingIntent),pendingIntent);

AlarmManager.AlarmClockInfo alarmClockInfo= alarmManager.getNextAlarmClock();

But the thing is setAlarmClock() is a onetime Alarm setting approach. whereas I need a repeating mechanism.

Correct me if my assumptions are untrue and also somewhere if I am not clear in explaining.

Please suggest me in this regard, will be very thankful for any of your suggestions.

Thanks in Advance

Note: both questions are not same.Because I am asking how could I achieve setRepeating kind of capability in setAlarmClock method.whereas the other post is asking for next alarm capability in the setRepeating method

sudha
  • 193
  • 13
  • Please don't ask the same question multiple times. You can edit your original question, add more relevant information, etc. Asking your question twice is just annoying. – David Wasser Dec 20 '17 at 12:42
  • both questions are not same.Because Iam asking how could I acheive setRepeating kind of capability in setAlarmClock method.whereas the other post is asking for nextalarm capabilty in setRepeating method – sudha Dec 20 '17 at 12:49

1 Answers1

0

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
  • I have an array of alarms say..9:00-3days,14:00-2 days,20:00-5 days..where iam setting these using setRepeating() and saving the related info like unique code and duration data into my SQLite db.I am able to acheive till here.My question is when 9:00 alarm strikes then I should show your next alarm is at 14:00 where I cant get this in setRepeating.But this functionality(get next alarm is in setAlarmClock) .so I was searching whether I have any repeating mechanism for setAlarmClock.... – sudha Dec 20 '17 at 12:45
  • There is no way to have repeating alarms using `setAlarmClock()`. The documentation is pretty clear about this. – David Wasser Dec 20 '17 at 14:04