2

I am setting alarams as follows:

 AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);

    alarm.setRepeating(AlarmManager.RTC_WAKEUP,
            calendar1.getTimeInMillis(), 24*60*60 * 1000, pintent);

Like this i am adding so many alarms with different time intervals.

So now i want to get next alarm time out of these.

For that i am using

  android.provider.Settings.System.getString(
                    getContentResolver(),
                    android.provider.Settings.System.NEXT_ALARM_FORMATTED)

but the above is not returning any thing.

Pls some body help me ..

karthik
  • 134
  • 1
  • 9

1 Answers1

0

Settings.System.NEXT_ALARM_FORMATTED returns the next alarm of your clock, like it is shown on the lockscreen.

The AlarmManager does not provide methods for the next execution. If your using AlarmManager.setInexactRepeating() (saves battery!) it won't be possible to determine the exact time anyway.

Why don't you store the execution time in SharedPreferences or a database when you're scheduling an alarm?

Gubbel
  • 2,327
  • 1
  • 24
  • 35
  • Hi Gubbel, Settings.System.NEXT_ALARM_FORMATTED will return only android alarm setted but not the alarm.setRepeating(AlarmManager.RTC_WAKEUP, calendar1.getTimeInMillis(), 24*60*60 * 1000, pintent); – karthik May 19 '11 at 14:22
  • That's what I wrote, maybe not clear enough though. You can't use this setting, because it has a completely different purpose. Also there seems to be no way to query the next alarm, so you will have to store the time yourself – Gubbel May 19 '11 at 16:59