alarm api the alarm api provides functionality for scheduling the system alarm it allows you to run other applications and have them perform operations at a specific time you can schedule an alarm to go off once or to repeat at specific intervals each application has its own individual alarm storage, that is, applications cannot view or edit alarms set by other applications once an alarm goes off, it will be removed from the alarm storage automatically alarmmanager provides methods to manage alarms such as adding and removing for more information on the alarm features, see alarm guide since 1 0 summary of interfaces and methods interface method alarmmanagerobject alarmmanager void add alarm alarm, applicationid applicationid, optional applicationcontrol? appcontrol void remove alarmid id void removeall alarm get alarmid id alarm[] getall alarm alarmrelative long? getremainingseconds alarmabsolute date? getnextscheduleddate 1 type definitions 1 1 alarmid an alarm identifier typedef domstring alarmid; since 1 0 1 2 bydayvalue specifies the values for the daysoftheweek attribute enum bydayvalue { "mo", "tu", "we", "th", "fr", "sa", "su" }; since 1 0 "mo" to "su" correspond to "monday" to "sunday" 2 interfaces 2 1 alarmmanagerobject the alarmmanagerobject interface defines what is instantiated by the tizen object from the tizen platform the tizen alarm object allows access to the functionality of the alarm api [nointerfaceobject] interface alarmmanagerobject { readonly attribute alarmmanager alarm; }; tizen implements alarmmanagerobject; since 1 0 2 2 alarmmanager the alarmmanager interface provides methods to manage alarms [nointerfaceobject] interface alarmmanager { const long period_minute = 60; const long period_hour = 3600; const long period_day = 86400; const long period_week = 604800; void add alarm alarm, applicationid applicationid, optional applicationcontrol? appcontrol raises webapiexception ; void remove alarmid id raises webapiexception ; void removeall raises webapiexception ; alarm get alarmid id raises webapiexception ; alarm[] getall raises webapiexception ; }; since 1 0 constants period_minute the period of a minute it defines the number of seconds per minute since 1 0 period_hour the period of an hour it defines the number of seconds per hour since 1 0 period_day the period of a day it defines the number of seconds per day since 1 0 period_week the period of a week it defines the number of seconds in a week since 1 0 methods add adds an alarm to the storage void add alarm alarm, applicationid applicationid, optional applicationcontrol? appcontrol ; since 1 0 sets an alarm with the application id to be run you should definitely provide the application id to run and the application control information if it is necessary for more information about the application control, see the application api privilege level public privilege http //tizen org/privilege/alarm parameters alarm an alarm to add it can be either alarmrelative or alarmabsolute applicationid the application id to run when the alarm is triggered appcontrol optional nullable the data structure describing application control details exceptions webapiexception with error type typemismatcherror, if any input parameter is not compatible with the expected type for that parameter with error type invalidvalueserror, if any input parameter does not contain a valid value with error type securityerror, if the application does not have the privilege to call this method with error type unknownerror, if any other error occurs code example // triggers an alarm on a given date/time var alarm = new tizen alarmabsolute new date 2014, 10, 4, 8, 0 ; var appcontrol = new tizen applicationcontrol "http //tizen org/appcontrol/operation/view" ; tizen alarm add alarm, tizen application getcurrentapplication appinfo id, appcontrol ; console log "alarm added with id " + alarm id ; remove removes an alarm from the storage void remove alarmid id ; since 1 0 if an alarm goes off, it will be removed from the storage automatically privilege level public privilege http //tizen org/privilege/alarm parameters id the id of the alarm to remove exceptions webapiexception with error type notfounderror, if this alarm identifier cannot be found in the storage with error type invalidvalueserror, if any input parameter does not contain a valid value with error type securityerror, if the application does not have the privilege to call this method with error type unknownerror, if the method cannot be completed because of an unknown error code example var alarms = tizen alarm getall ; // removes the first alarm if alarms length > 0 { try { tizen alarm remove alarms[0] id ; console log "successfully removed the first alarm " ; } catch error { console log "failed to remove the first alarm " ; } } removeall removes all alarms added by an application void removeall ; since 1 0 because each application has its own alarm storage, this method removes alarms only added by the calling application privilege level public privilege http //tizen org/privilege/alarm exceptions webapiexception with error type securityerror, if the application does not have the privilege to call this method with error type unknownerror, if the method cannot be completed because of an unknown error code example tizen alarm removeall ; console log "remove all registered alarms in the storage " ; get returns an alarm as per the specified identifier alarm get alarmid id ; since 1 0 parameters id the alarm id to retrieve return value alarm an alarm object with the specified id exceptions webapiexception with error type notfounderror, if this alarm identifier cannot be found in the storage with error type invalidvalueserror, if any input parameter does not contain a valid value with error type unknownerror, if the method cannot be completed because of an unknown error code example // sets an alarm var date = new date ; date sethours date gethours +1 ; var abs_alarm = new tizen alarmabsolute date ; // adds an alarm tizen alarm add abs_alarm, tizen application getcurrentapplication appinfo id ; // gets an alarm var alarm = tizen alarm get abs_alarm id ; console log "the alarm will trigger at " + alarm getnextscheduleddate ; getall retrieves all alarms in an application storage alarm[] getall ; since 1 0 alarms that have already been triggered are removed automatically from the storage return value alarm[] all alarm objects exceptions webapiexception with error type unknownerror, if the method cannot be completed because of an unknown error code example var alarms = tizen alarm getall ; console log alarms length + " alarms present in the storage " ; 2 3 alarm the alarm interface is an abstract interface for alarm types [nointerfaceobject] interface alarm { readonly attribute alarmid? id; }; since 1 0 attributes readonly alarmid id the alarm identifier since 1 0 2 4 alarmrelative the alarmrelative interface provides the relative alarm, which occurs at a fixed interval in future [constructor long delay, optional long? period ] interface alarmrelative alarm { readonly attribute long delay; readonly attribute long? period; long? getremainingseconds raises webapiexception ; }; since 1 0 this alarm triggers after a duration mentioned in the delay attribute from the moment the alarm is added if a period is provided, the alarm keeps triggering for the given interval remark since tizen 2 4 behaviour of this alarm has changed in order to decrease the power consumption, the operating system decides when this alarm is going to be fired and what is the period between subsequent executions it is guaranteed that this alarm will be fired after at least delay seconds if period is provided, it will be adjusted by the operating system, however this value will not be lower than 600 seconds code example // gets the current application id var appid = tizen application getcurrentapplication appinfo id; // sets an alarm in 3 hours from now var alarm1 = new tizen alarmrelative 3 * tizen alarm period_hour ; tizen alarm add alarm1, appid ; // sets an alarm in one hour, recurring after every 10 minutes var alarm2 = new tizen alarmrelative tizen alarm period_hour, 10 * tizen alarm period_minute ; tizen alarm add alarm2, appid ; constructors alarmrelative long delay, optional long? period ; attributes readonly long delay an attribute to store the difference in time in seconds between when an alarm is added and when it is triggered since 1 0 remark since tizen 2 4 the operating system adjusts this value to decrease the power consumption readonly long nullable an attribute to store the duration in seconds between each trigger of an alarm by default, this attribute is set to null, indicating that this alarm does not repeat since 1 0 remark since tizen 2 4 the operating system adjusts this value to decrease the power consumption methods getremainingseconds returns the duration in seconds before the next alarm is triggered long? getremainingseconds ; since 1 0 if the alarm has expired, this method returns null return value long the duration before the next alarm is triggered exceptions webapiexception with error type unknownerror, if the method cannot be completed because of an unknown error code example // gets the current application id var appid = tizen application getcurrentapplication appinfo id; // sets an alarm in 3 hours from now var alarm = new tizen alarmrelative 3 * tizen alarm period_hour ; tizen alarm add alarm, appid ; var sec = alarm getremainingseconds ; console log "remaining time is " + sec ; 2 5 alarmabsolute the alarmabsolute interface provides an absolute alarm, which triggers at a specified absolute date [constructor date date , constructor date date, bydayvalue[] daysoftheweek , constructor date date, long period ] interface alarmabsolute alarm { readonly attribute date date; readonly attribute long? period; readonly attribute bydayvalue[] daysoftheweek; date? getnextscheduleddate raises webapiexception ; }; since 1 0 if a period is provided, the alarm keeps triggering for the given interval if the daysoftheweek array is not empty, the alarm triggers every week, for the given days, at the time defined by the date attribute code example // gets the current application id var appid = tizen application getcurrentapplication appinfo id; // sets an alarm on january 1st 2014 08 00 var date = new date 2014, 0, 1, 8, 0 ; var alarm1 = new tizen alarmabsolute date ; tizen alarm add alarm1, appid ; // sets an alarm on january 1st 2014 08 00, repeating every 2 days var alarm2 = new tizen alarmabsolute date, 2 * tizen alarm period_day ; tizen alarm add alarm2, appid ; // sets an alarm occurring on every saturday and sunday, at 08 00, starting from january 1st 2014 var alarm3 = new tizen alarmabsolute date, ["sa", "su"] ; tizen alarm add alarm3, appid ; constructors alarmabsolute date date ; alarmabsolute date date, bydayvalue[] daysoftheweek ; alarmabsolute date date, long period ; attributes readonly date date an attribute to store the absolute date/time when the alarm is initially triggered this attribute is precise to the second milliseconds will be ignored since 1 0 readonly long period [nullable] an attribute to store the duration in seconds between each trigger of the alarm by default, this attribute is set to null, indicating that this alarm does not repeat the _period_ and _daysoftheweek_ attributes are mutually exclusive since 1 0 readonly bydayvalue daysoftheweek an attribute to store the days of the week associated with the recurrence rule by default, this attribute is set to an empty array the _period_ and _daysoftheweek_ attributes are mutually exclusive since 1 0 methods getnextscheduleddate returns the date / time of the next alarm trigger date? getnextscheduleddate ; since 1 0 if the alarm has expired, this method returns null the returned date is precise to the second return value date the date/time of the next alarm trigger exceptions webapiexception with error type unknownerror, if the method cannot be completed because of an unknown error code example // gets the current application id var appid = tizen application getcurrentapplication appinfo id; // sets an alarm on january 1st 2014 08 00 var date = new date 2014, 0, 1, 8, 0 ; var alarm1 = new tizen alarmabsolute date ; tizen alarm add alarm1, appid ; var date = alarm1 getnextscheduleddate ; console log "next scheduled time is " + date ; 3 full webidl module alarm { typedef domstring alarmid; enum bydayvalue { "mo", "tu", "we", "th", "fr", "sa", "su" }; [nointerfaceobject] interface alarmmanagerobject { readonly attribute alarmmanager alarm; }; tizen implements alarmmanagerobject; [nointerfaceobject] interface alarmmanager { const long period_minute = 60; const long period_hour = 3600; const long period_day = 86400; const long period_week = 604800; void add alarm alarm, applicationid applicationid, optional applicationcontrol? appcontrol raises webapiexception ; void remove alarmid id raises webapiexception ; void removeall raises webapiexception ; alarm get alarmid id raises webapiexception ; alarm[] getall raises webapiexception ; }; [nointerfaceobject] interface alarm { readonly attribute alarmid? id; }; [constructor long delay, optional long? period ] interface alarmrelative alarm { readonly attribute long delay; readonly attribute long? period; long? getremainingseconds raises webapiexception ; }; [constructor date date , constructor date date, bydayvalue[] daysoftheweek , constructor date date, long period ] interface alarmabsolute alarm { readonly attribute date date; readonly attribute long? period; readonly attribute bydayvalue[] daysoftheweek; date? getnextscheduleddate raises webapiexception ; }; };