Android Tutorial

(avery) #1
Android Tutorial 421

notify.ledARGB = Color.RED;
notify.ledOnMS = 50;
notify.ledOffMS = 50;
}


The blinking light continues until the Notification is cleared by the
user. The use of the Notification.FLAG_INSISTENT flag does not
affect this as it does vibration effects.

Color and blinking rates could also be used to indicate other
information. For instance, temperature from a weather service
could be indicated with red and blue plus blink rate. Use of such
colors for passive data indication can be useful even when other
forms would work. It is far less intrusive than annoying, loud
ringers or harsh, vibrating phone noises. For instance, a simple
glance at the handset could tell the user some useful piece of
information without the need to launch any applications or change
what they are doing.

Making Noise

Sometimes, the handset has to make noise to get the user’s
attention. Luckily, the Android SDK provides a means for this using
the Notification object. Begin by configuring the audio stream type
to use when playing a sound. Generally, the most useful stream
type is STREAM_NOTIFICATION. You can configure the audio
stream type on your notification as follows:

notify.audioStreamType = AudioManager.STREAM_NOTIFICATION;


Now, assign a valid Uri object to the sound member variable and
that sound plays when the notification is triggered. The following
Free download pdf