background image
C H A P T E R 1 7
Additional System Services
Using Additional System Services
17-11
Using Alerts and Alarms
17
This section describes the use of functions and methods that provide alerts and
alarms, and the
protoPeriodicAlarmEditor
.
Using the Notify Method to Display User Alerts
17
The
Notify
method offers a simple way to display a message to the user. This
method takes three arguments. The first specifies which type of alert is displayed;
some alerts beep, some only log their notice instead of displaying it, and so on. The
other two arguments are strings shown to the user in the alert.
The following code fragment creates the slip shown in Figure 17-7:
:Notify(kNotifyAlert,"LlamaCalc",
"You've run out of Llamas!");
Figure 17-7
A user alert
Creating Alarms
17
The
AddAlarm
and
AddAlarmInSeconds
functions are used to schedule a new
alarm. You can also use these functions to substitute a new alarm for one that is
currently scheduled but has not yet executed.
The
AddAlarm
function creates each new alarm as a soup entry (thus, alarms
persist across restarts) and returns an alarm key that uniquely identifies the new
alarm. This alarm key is a string you provide as one of the arguments to the
function that creates the alarm; it includes your developer signature as a suffix. For
example, a typical alarm key might be the string
"lunch:myApp:mySig"
or
something similar. Note that only the first 24 characters of an alarm key are
significant.
IMPORTANT
Do not manipulate the alarm soup or its entries directly. Use only
the interface described in this chapter to manipulate alarms.
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна