Android Tutorial

(avery) #1
Android Tutorial 419

accomplished by describing the vibrate member variable, which
determines the vibration pattern. An array of long values describes
the vibration duration. Thus, the following line of code enabled a
simple vibration pattern that occurs whenever the notification is
triggered:

notify.vibrate = new long[] {0, 200, 200, 600, 600};


This vibration pattern vibrates for 200 milliseconds and then stops
vibrating for 200 milliseconds. After that, it vibrates for 600
milliseconds and then stops for that long. To repeat the Notification
alert, a notification flag can be set so it doesn’t stop until the user
clears the notification.

notify.flags |= Notification.FLAG_INSISTENT;


An application can use different patterns of vibrations to alert the
user to different types of events or even present counts. For
instance, think about a grandfather clock with which you can
deduce the time based on the tones that are played.

Blinking the Lights

Blinking lights are a great way to pass information silently to the
user when other forms of alert are not appropriate. The Android
SDK provides reasonable control over a multicolored indicator light,
when such a light is available on the device. Users might recognize
this light as a service indicator or battery level warning. An
application can take advantage of this light as well, by changing the
blinking rate or color of the light.
Free download pdf