android - get time of the next alarm

前端 未结 3 1715
野性不改
野性不改 2020-12-28 20:46

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

Thanks

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

相关标签:
3条回答
  • 2020-12-28 20:46
    String nextAlarm = Settings.System.getString(getContentResolver(),
        Settings.System.NEXT_ALARM_FORMATTED);
    
    0 讨论(0)
  • 2020-12-28 20:48

    Needs to be:

    String nextAlarm = android.provider.Settings.System.getString(getContentResolver(), android.provider.Settings.System.NEXT_ALARM_FORMATTED);
    
    0 讨论(0)
  • 2020-12-28 21:13

    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 讨论(0)
提交回复
热议问题