Android APIs
public final class

AlarmClock

extends Object
java.lang.Object
   ↳ android.provider.AlarmClock

Class Overview

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_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 EXTRA_DAYS Bundle extra: Weekdays for repeating alarm.
String EXTRA_HOUR Bundle extra: The hour 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()
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ACTION_SET_ALARM

Added in API level 9

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.

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"

public static final String ACTION_SET_TIMER

Added in API level 19

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"

public static final String ACTION_SHOW_ALARMS

Added in API level 19

Activity Action: Show the alarms.

This action opens the alarms page.

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

public static final String EXTRA_DAYS

Added in API level 19

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"

public static final String EXTRA_HOUR

Added in API level 9

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.

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

public static final String EXTRA_LENGTH

Added in API level 19

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"

public static final String EXTRA_MESSAGE

Added in API level 9

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

Used by ACTION_SET_ALARM and ACTION_SET_TIMER.

The value is a String.

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

public static final String EXTRA_MINUTES

Added in API level 9

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.

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

public static final String EXTRA_RINGTONE

Added in API level 19

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.

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

public static final String EXTRA_SKIP_UI

Added in API level 11

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.

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

public static final String EXTRA_VIBRATE

Added in API level 19

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

Used by ACTION_SET_ALARM.

The value is a Boolean. The default is true.

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

public static final String VALUE_RINGTONE_SILENT

Added in API level 19

Bundle extra value: Indicates no ringtone should be played.

Used by ACTION_SET_ALARM, passed in through EXTRA_RINGTONE.

Constant Value: "silent"

Public Constructors

public AlarmClock ()

Added in API level 9