14

Is there a way in Android to get the upcoming alarm time?

Thanks

Clarification: I am talking about the native android Alarm Clock appliction

5
  • 2
    As in the alarm clock application, or an Alarm event triggered by an application? Apr 8, 2010 at 13:54
  • is the alarm time of the Native Alarm Clock application. Apr 8, 2010 at 14:21
  • 1
    @Jim Blackler, do you know the answer if it is an Alarm event triggered by an application? Thanks for your answer in advance :-)
    – monn3t
    Jun 3, 2011 at 15:33
  • @monn3t I am answering very late but may be it would help others. You can save the alarm event somewhere persistent like database, sharedpreferences etc Sep 14, 2016 at 22:15
  • @FawadKhalil, thanks for your answer. As you can see this question is from a long time ago. Things have changed drastically with the OS ever since. However, I believe your answer is still current. Thanks
    – monn3t
    Nov 17, 2016 at 10:05

3 Answers 3

20

Starting with API level 21 the constant Settings.System.NEXT_ALARM_FORMATTED is deprecated.

Instead, you should use:

AlarmManager.getNextAlarmClock()

https://developer.android.com/reference/android/app/AlarmManager.html#getNextAlarmClock()

0
13
String nextAlarm = Settings.System.getString(getContentResolver(),
    Settings.System.NEXT_ALARM_FORMATTED);
5
  • 5
    is there any ways to get next alarm time in seconds,rather than a formatted time string?
    – peterlawn
    May 30, 2011 at 6:55
  • Did someone find a way to read the time in seconds to the next alarm ?
    – Lukap
    Nov 15, 2011 at 8:57
  • I'd like to see a perfect solution too. A formatted string is simply not sufficient for most cases.. May 5, 2013 at 8:47
  • What about alarm time set by third party apps? Any chances getting that value? Aug 16, 2014 at 18:06
  • @Steve, how can I get the time of next alarm from the alarm manager?
    – Kala J
    Oct 21, 2014 at 16:16
1

Needs to be:

String nextAlarm = android.provider.Settings.System.getString(getContentResolver(), android.provider.Settings.System.NEXT_ALARM_FORMATTED);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.