Daniel Benedykt
Daniel Benedykt

Reputation: 6553

android - get time of the next alarm

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

Thanks

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

Upvotes: 14

Views: 15331

Answers (3)

OlegKrikun
OlegKrikun

Reputation: 644

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

Upvotes: 20

Freddroid
Freddroid

Reputation: 2459

Needs to be:

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

Upvotes: 1

Steve
Steve

Reputation: 55615

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

Upvotes: 13

Related Questions