Skip to content

Most visited

Recently visited

navigation
Added in API level 9

AlarmClock

public final class AlarmClock
extends Object

java.lang.Object
   ↳ 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 Context.startActivity() so that the user has the option of choosing which alarm clock application to use.

Summary

Constants

String ACTION_DISMISS_ALARM

Activity Action: Dismiss an alarm.

String ACTION_SET_ALARM

Activity Action: Set an alarm.

String ACTION_SET_TIMER

Activity Action: Set a timer.

String ACTION_SHOW_ALARMS

Activity Action: Show the alarms.

String ACTION_SNOOZE_ALARM

Activity Action: Snooze a currently ringing alarm.

String ALARM_SEARCH_MODE_ALL

Selects all alarms.

String ALARM_SEARCH_MODE_LABEL

Search by alarm label.

String ALARM_SEARCH_MODE_NEXT

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

String ALARM_SEARCH_MODE_TIME

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

String EXTRA_ALARM_SEARCH_MODE

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

String EXTRA_ALARM_SNOOZE_DURATION

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

String EXTRA_DAYS

Bundle extra: Weekdays for repeating alarm.

String EXTRA_HOUR

Bundle extra: The hour of the alarm.

String EXTRA_IS_PM

Bundle extra: The AM/PM of the alarm.

String EXTRA_LENGTH

Bundle extra: The length of the timer in seconds.

String EXTRA_MESSAGE

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

String EXTRA_MINUTES

Bundle extra: The minutes of the alarm.

String EXTRA_RINGTONE

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

String EXTRA_SKIP_UI

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

String EXTRA_VIBRATE

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

String VALUE_RINGTONE_SILENT

Bundle extra value: Indicates no ringtone should be played.

Public constructors

AlarmClock()

Inherited methods

From class java.lang.Object

Constants

ACTION_DISMISS_ALARM

Added in API level 23
String ACTION_DISMISS_ALARM

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 CATEGORY_VOICE and the activity is started in Voice Interaction mode (i.e. check isVoiceInteraction()), then the implementation should additionally use 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).

See also:

Constant Value: "android.intent.action.DISMISS_ALARM"

ACTION_SET_ALARM

Added in API level 9
String ACTION_SET_ALARM

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 isVoiceInteraction(), and if true, the implementation should report a deeplink of the created/enabled alarm using 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.

Constant Value: "android.intent.action.SET_ALARM"

ACTION_SET_TIMER

Added in API level 19
String ACTION_SET_TIMER

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.

Constant Value: "android.intent.action.SET_TIMER"

ACTION_SHOW_ALARMS

Added in API level 19
String ACTION_SHOW_ALARMS

Activity Action: Show the alarms.

This action opens the alarms page.

Constant Value: "android.intent.action.SHOW_ALARMS"

ACTION_SNOOZE_ALARM

Added in API level 23
String ACTION_SNOOZE_ALARM

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.

See also:

Constant Value: "android.intent.action.SNOOZE_ALARM"

ALARM_SEARCH_MODE_ALL

Added in API level 23
String ALARM_SEARCH_MODE_ALL

Selects all alarms.

See also:

Constant Value: "android.all"

ALARM_SEARCH_MODE_LABEL

Added in API level 23
String ALARM_SEARCH_MODE_LABEL

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

See also:

Constant Value: "android.label"

ALARM_SEARCH_MODE_NEXT

Added in API level 23
String ALARM_SEARCH_MODE_NEXT

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

See also:

Constant Value: "android.next"

ALARM_SEARCH_MODE_TIME

Added in API level 23
String ALARM_SEARCH_MODE_TIME

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.

See also:

Constant Value: "android.time"

EXTRA_ALARM_SEARCH_MODE

Added in API level 23
String EXTRA_ALARM_SEARCH_MODE

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:

See also:

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

EXTRA_ALARM_SNOOZE_DURATION

Added in API level 23
String EXTRA_ALARM_SNOOZE_DURATION

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.

See also:

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

EXTRA_DAYS

Added in API level 19
String EXTRA_DAYS

Bundle extra: Weekdays for repeating alarm.

Used by ACTION_SET_ALARM.

The value is an ArrayList. Each item can be:

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

EXTRA_HOUR

Added in API level 9
String EXTRA_HOUR

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.

See also:

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

EXTRA_IS_PM

Added in API level 23
String EXTRA_IS_PM

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.

See also:

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

EXTRA_LENGTH

Added in API level 19
String EXTRA_LENGTH

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

See also:

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

EXTRA_MESSAGE

Added in API level 9
String EXTRA_MESSAGE

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

Used by ACTION_SET_ALARM and ACTION_SET_TIMER.

The value is a String.

See also:

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

EXTRA_MINUTES

Added in API level 9
String EXTRA_MINUTES

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.

See also:

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

EXTRA_RINGTONE

Added in API level 19
String EXTRA_RINGTONE

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.

See also:

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

EXTRA_SKIP_UI

Added in API level 11
String EXTRA_SKIP_UI

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.

See also:

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

EXTRA_VIBRATE

Added in API level 19
String EXTRA_VIBRATE

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

Used by ACTION_SET_ALARM.

The value is a Boolean. The default is true.

See also:

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

VALUE_RINGTONE_SILENT

Added in API level 19
String VALUE_RINGTONE_SILENT

Bundle extra value: Indicates no ringtone should be played.

Used by ACTION_SET_ALARM, passed in through EXTRA_RINGTONE.

See also:

Constant Value: "silent"

Public constructors

AlarmClock

Added in API level 9
AlarmClock ()

This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.