Added in API level 9

AlarmClock


class AlarmClock
kotlin.Any
   ↳ android.provider.AlarmClock

The AlarmClock provider contains an Intent action and extras that can be used to start an Activity to set a new alarm or timer in an alarm clock application. Applications that wish to receive the ACTION_SET_ALARM and ACTION_SET_TIMER Intents should create an activity to handle the Intent that requires the permission com.android.alarm.permission.SET_ALARM. Applications that wish to create a new alarm or timer should use android.content.Context#startActivity so that the user has the option of choosing which alarm clock application to use. Android TV devices may not support the alarm intents.

Summary

Constants
static String

Activity Action: Dismiss an alarm.

static String

Activity Action: Dismiss a timer.

static String

Activity Action: Set an alarm.

static String

Activity Action: Set a timer.

static String

Activity Action: Show the alarms.

static String

Activity Action: Show the timers.

static String

Activity Action: Snooze a currently ringing alarm.

static String

Selects all alarms.

static String

Search by alarm label.

static String

Selects the alarm that will ring next, or the alarm that is currently ringing, if any.

static String

Search for the alarm that is most closely matched by the search parameters EXTRA_HOUR, EXTRA_MINUTES, EXTRA_IS_PM.

static String

Bundle extra: Specify the type of search mode to look up an alarm.

static String

Bundle extra: The snooze duration of the alarm in minutes.

static String

Bundle extra: Weekdays for repeating alarm.

static String

Bundle extra: The hour of the alarm.

static String

Bundle extra: The AM/PM of the alarm.

static String

Bundle extra: The length of the timer in seconds.

static String

Bundle extra: A custom message for the alarm or timer.

static String

Bundle extra: The minutes of the alarm.

static String

Bundle extra: A ringtone to be played with this alarm.

static String

Bundle extra: Whether or not to display an activity after performing the action.

static String

Bundle extra: Whether or not to activate the device vibrator.

static String

Bundle extra value: Indicates no ringtone should be played.

Public constructors

Constants

ACTION_DISMISS_ALARM

Added in API level 23
static val ACTION_DISMISS_ALARM: String

Activity Action: Dismiss an alarm.

The alarm to dismiss can be specified or searched for in one of the following ways:

  1. The Intent's data URI, which represents a deeplink to the alarm.
  2. The extra EXTRA_ALARM_SEARCH_MODE to determine how to search for the alarm.

If neither of the above are given then:

  • If exactly one active alarm exists, it is dismissed.
  • If more than one active alarm exists, the user is prompted to choose the alarm to dismiss.

If the extra EXTRA_ALARM_SEARCH_MODE is used, and the search results contain two or more matching alarms, then the implementation should show an UI with the results and allow the user to select the alarm to dismiss. If the implementation supports android.content.Intent#CATEGORY_VOICE and the activity is started in Voice Interaction mode (i.e. check android.app.Activity#isVoiceInteraction), then the implementation should additionally use android.app.VoiceInteractor.PickOptionRequest to start a voice interaction follow-on flow to help the user disambiguate the alarm by voice.

If the specified alarm is a single occurrence alarm, then dismissing it effectively disables the alarm; it will never ring again unless explicitly re-enabled.

If the specified alarm is a repeating alarm, then dismissing it only prevents the upcoming instance from ringing. The alarm remains enabled so that it will still ring on the date and time of the next instance (i.e. the instance after the upcoming one).

Value: "android.intent.action.DISMISS_ALARM"

ACTION_DISMISS_TIMER

Added in API level 28
static val ACTION_DISMISS_TIMER: String

Activity Action: Dismiss a timer.

The timer to dismiss should be specified using the Intent's data URI, which represents a deeplink to the timer.

If no data URI is provided, dismiss all expired timers.

Value: "android.intent.action.DISMISS_TIMER"

ACTION_SET_ALARM

Added in API level 9
static val ACTION_SET_ALARM: String

Activity Action: Set an alarm.

Activates an existing alarm or creates a new one.

This action requests an alarm to be set for a given time of day. If no time of day is specified, an implementation should start an activity that is capable of setting an alarm (EXTRA_SKIP_UI is ignored in this case). If a time of day is specified, and EXTRA_SKIP_UI is true, and the alarm is not repeating, the implementation should remove this alarm after it has been dismissed. If an identical alarm exists matching all parameters, the implementation may re-use it instead of creating a new one (in this case, the alarm should not be removed after dismissal).

This action always enables the alarm.

This activity could also be started in Voice Interaction mode. The activity should check android.app.Activity#isVoiceInteraction, and if true, the implementation should report a deeplink of the created/enabled alarm using android.app.VoiceInteractor.CompleteVoiceRequest. This allows follow-on voice actions such as ACTION_DISMISS_ALARM to dismiss the alarm that was just enabled.

Request parameters

  • EXTRA_HOUR (optional): The hour of the alarm being set.
  • EXTRA_MINUTES (optional): The minutes of the alarm being set.
  • EXTRA_DAYS (optional): Weekdays for repeating alarm.
  • EXTRA_MESSAGE (optional): A custom message for the alarm.
  • EXTRA_RINGTONE (optional): A ringtone to play with this alarm.
  • EXTRA_VIBRATE (optional): Whether or not to activate the device vibrator for this alarm.
  • EXTRA_SKIP_UI (optional): Whether or not to display an activity for setting this alarm.
Value: "android.intent.action.SET_ALARM"

ACTION_SET_TIMER

Added in API level 19
static val ACTION_SET_TIMER: String

Activity Action: Set a timer.

Activates an existing timer or creates a new one.

This action requests a timer to be started for a specific length of time. If no length is specified, the implementation should start an activity that is capable of setting a timer (EXTRA_SKIP_UI is ignored in this case). If a length is specified, and EXTRA_SKIP_UI is true, the implementation should remove this timer after it has been dismissed. If an identical, unused timer exists matching both parameters, an implementation may re-use it instead of creating a new one (in this case, the timer should not be removed after dismissal). This action always starts the timer.

Request parameters

  • EXTRA_LENGTH (optional): The length of the timer being set.
  • EXTRA_MESSAGE (optional): A custom message for the timer.
  • EXTRA_SKIP_UI (optional): Whether or not to display an activity for setting this timer.
Value: "android.intent.action.SET_TIMER"

ACTION_SHOW_ALARMS

Added in API level 19
static val ACTION_SHOW_ALARMS: String

Activity Action: Show the alarms.

This action opens the alarms page.

Value: "android.intent.action.SHOW_ALARMS"

ACTION_SHOW_TIMERS

Added in API level 26
static val ACTION_SHOW_TIMERS: String

Activity Action: Show the timers.

This action opens the timers page.

Value: "android.intent.action.SHOW_TIMERS"

ACTION_SNOOZE_ALARM

Added in API level 23
static val ACTION_SNOOZE_ALARM: String

Activity Action: Snooze a currently ringing alarm.

Snoozes the currently ringing alarm. The extra EXTRA_ALARM_SNOOZE_DURATION can be optionally set to specify the snooze duration; if unset, the implementation should use a reasonable default, for example 10 minutes. The alarm should ring again after the snooze duration.

Note: setting the extra EXTRA_ALARM_SNOOZE_DURATION does not change the default snooze duration; it's only applied to the currently ringing alarm.

If there is no currently ringing alarm, then this is a no-op.

Value: "android.intent.action.SNOOZE_ALARM"

ALARM_SEARCH_MODE_ALL

Added in API level 23
static val ALARM_SEARCH_MODE_ALL: String

Selects all alarms.

Value: "android.all"

ALARM_SEARCH_MODE_LABEL

Added in API level 23
static val ALARM_SEARCH_MODE_LABEL: String

Search by alarm label. Should return alarms that contain the word or phrase in given label.

Value: "android.label"

ALARM_SEARCH_MODE_NEXT

Added in API level 23
static val ALARM_SEARCH_MODE_NEXT: String

Selects the alarm that will ring next, or the alarm that is currently ringing, if any.

Value: "android.next"

ALARM_SEARCH_MODE_TIME

Added in API level 23
static val ALARM_SEARCH_MODE_TIME: String

Search for the alarm that is most closely matched by the search parameters EXTRA_HOUR, EXTRA_MINUTES, EXTRA_IS_PM. In this search mode, at least one of these additional extras are required.

Value: "android.time"

EXTRA_ALARM_SEARCH_MODE

Added in API level 23
static val EXTRA_ALARM_SEARCH_MODE: String

Bundle extra: Specify the type of search mode to look up an alarm.

For example, used by ACTION_DISMISS_ALARM to identify the alarm to dismiss.

This extra is only used when the alarm is not already identified by a deeplink as specified in the Intent's data URI.

The value of this extra is a String, restricted to the following set of supported search modes:

Value: "android.intent.extra.alarm.SEARCH_MODE"

EXTRA_ALARM_SNOOZE_DURATION

Added in API level 23
static val EXTRA_ALARM_SNOOZE_DURATION: String

Bundle extra: The snooze duration of the alarm in minutes.

Used by ACTION_SNOOZE_ALARM. This extra is optional and the value is an Integer that specifies the duration in minutes for which to snooze the alarm.

Value: "android.intent.extra.alarm.SNOOZE_DURATION"

EXTRA_DAYS

Added in API level 19
static val EXTRA_DAYS: String

Bundle extra: Weekdays for repeating alarm.

Used by ACTION_SET_ALARM.

The value is an ArrayList<Integer>. Each item can be:

Value: "android.intent.extra.alarm.DAYS"

EXTRA_HOUR

Added in API level 9
static val EXTRA_HOUR: String

Bundle extra: The hour of the alarm.

Used by ACTION_SET_ALARM.

This extra is optional. If not provided, an implementation should open an activity that allows a user to set an alarm with user provided time.

The value is an Integer and ranges from 0 to 23.

Value: "android.intent.extra.alarm.HOUR"

EXTRA_IS_PM

Added in API level 23
static val EXTRA_IS_PM: String

Bundle extra: The AM/PM of the alarm.

Used by ACTION_DISMISS_ALARM.

This extra is optional and only used when EXTRA_ALARM_SEARCH_MODE is set to ALARM_SEARCH_MODE_TIME. In this search mode, the EXTRA_IS_PM is used together with EXTRA_HOUR and EXTRA_MINUTES. The implementation should look up the alarm that is most closely matched by these search parameters. If EXTRA_IS_PM is missing, then the AM/PM of the specified EXTRA_HOUR is ambiguous and the implementation should ask for clarification from the user.

The value is a Boolean, where false=AM and true=PM.

Value: "android.intent.extra.alarm.IS_PM"

EXTRA_LENGTH

Added in API level 19
static val EXTRA_LENGTH: String

Bundle extra: The length of the timer in seconds.

Used by ACTION_SET_TIMER.

This extra is optional. If not provided, an implementation should open an activity that allows a user to set a timer with user provided length.

The value is an Integer and ranges from 1 to 86400 (24 hours).

Value: "android.intent.extra.alarm.LENGTH"

EXTRA_MESSAGE

Added in API level 9
static val EXTRA_MESSAGE: String

Bundle extra: A custom message for the alarm or timer.

Used by ACTION_SET_ALARM and ACTION_SET_TIMER.

The value is a String.

Value: "android.intent.extra.alarm.MESSAGE"

EXTRA_MINUTES

Added in API level 9
static val EXTRA_MINUTES: String

Bundle extra: The minutes of the alarm.

Used by ACTION_SET_ALARM.

The value is an Integer and ranges from 0 to 59. If not provided, it defaults to 0.

Value: "android.intent.extra.alarm.MINUTES"

EXTRA_RINGTONE

Added in API level 19
static val EXTRA_RINGTONE: String

Bundle extra: A ringtone to be played with this alarm.

Used by ACTION_SET_ALARM.

This value is a String and can either be set to VALUE_RINGTONE_SILENT or to a content URI of the media to be played. If not specified or the URI doesn't exist, "content://settings/system/alarm_alert will be used.

Value: "android.intent.extra.alarm.RINGTONE"

EXTRA_SKIP_UI

Added in API level 11
static val EXTRA_SKIP_UI: String

Bundle extra: Whether or not to display an activity after performing the action.

Used by ACTION_SET_ALARM and ACTION_SET_TIMER.

If true, the application is asked to bypass any intermediate UI. If false, the application may display intermediate UI like a confirmation dialog or settings.

The value is a Boolean. The default is false.

Value: "android.intent.extra.alarm.SKIP_UI"

EXTRA_VIBRATE

Added in API level 19
static val EXTRA_VIBRATE: String

Bundle extra: Whether or not to activate the device vibrator.

Used by ACTION_SET_ALARM.

The value is a Boolean. The default is true.

Value: "android.intent.extra.alarm.VIBRATE"

VALUE_RINGTONE_SILENT

Added in API level 19
static val VALUE_RINGTONE_SILENT: String

Bundle extra value: Indicates no ringtone should be played.

Used by ACTION_SET_ALARM, passed in through EXTRA_RINGTONE.

Value: "silent"

Public constructors

AlarmClock

AlarmClock()