Home » Android » android – get time of the next alarm

android – get time of the next alarm

Posted by: admin May 14, 2020 Leave a comment

Questions:

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

Thanks

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

How to&Answers:
String nextAlarm = Settings.System.getString(getContentResolver(),
    Settings.System.NEXT_ALARM_FORMATTED);

Answer:

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()

Answer:

Needs to be:

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