Samsung Web API enables you to schedule an application to be run at a specific time using the Alarm API. When an alarm is triggered, the application is launched (unless it is already running).
The main features of the Alarm API include:
- Alarm management
You can manage alarms by creating and deleting them. Both relative and absolute alarms are available: the relative alarm is triggered after a specified delay from the moment it is created, while an absolute alarm is triggered at a specified time and date.
You can also create a recurring alarm that is repeated after a specified period of time, or on the given days of the week at a defined time.
With the getAll() method, you can obtain a list of all existing alarms on the device.
- Application launches with alarms
You can set an alarm to launch an application when triggered.
- Alarm events
You can retrieve information about the next alarm event using the AlarmAbsolute:Alarm and AlarmRelative:Alarm interfaces. They provide the time and date of the next scheduled absolute alarm, or the time remaining before the next relative alarm.
To define a time period for the relative alarm or for the recurrence of an absolute alarm, you can use the following predefined constants from the Alarm API:
- webapis.alarm.PERIOD_MINUTE represents the number of seconds in a minute (60).
- webapis.alarm.PERIOD_HOUR represents the number of seconds in an hour (3600).
- webapis.alarm.PERIOD_DAY represents the number of seconds in a day (86400).
- webapis.alarm.PERIOD_WEEK represents the number of seconds in a week (604800).