Figure 14-1: The status bar, with a couple icons present.
Deconstructing the Status Bar
Figure 14-1 shows the status bar, the area where you can notify the user of an event. The status bar can hold many icons. The status bar shown in Figure 14-1 holds, starting on the left, a calendar notification announcing an appointment, and an icon signifying that USB debugging is enabled.
Figure 14-1: The status bar, with a couple icons present.
Users can also swipe the status bar downward to see more information, as shown in Figure 14-2. Every status bar icon now has an expanded view, where more information can be shown.
Figure 14-2: Opening the status bar.
You can inform users of various activities, such as device state, mail notifications, and even download progress, as shown in Figure 14-3.
Figure 14-3: The progress loader on the status bar.
Adding an icon to the status bar isn’t your only option for alerting the user to a notification. You can augment a notification using one — or more — of these three options:
Vibration: The device vibrates briefly when a notification is received — useful when the device is in the user’s pocket.
Sound: An alarm sounds when the notification is received. A ringtone or a prerecorded tone that you install along with your application is useful when the user has cranked up the notification sound level.
Light: The LED light on the device flashes at a given interval in the color you specify. (Many devices contain an LED that you can program.) If the LED supports only a single color, such as white, it flashes in that color and ignores your color specification. If the user has set the volume level to silent, the light provides an excellent cue that something needs attention.
Android 4.1 Jelly Bean introduces dramatic improvements to Android notifications. Devices that run Jelly Bean can have notifications with these features:
Expandable preview: The user can expand a notification by using the pinch-and-zoom gesture. The expandable notification is a helpful way to show users an expanded preview of the notification content, such as a message preview for an e-mail application.
Action buttons: A user has always been able to tap a notification to launch the app that created it. However, you can add as many as three additional buttons to a Jelly Bean app to make it perform whatever operations you want. One outstanding example in the Task Reminder app is having the Snooze button temporarily dismiss the notification and bring it back later.
Varied template styles: Jelly Bean ships with three new styles of notifications, as shown in Figure 14-4:
• BigTextStyle
: Shows a multiline TextView
• BigInboxStyle
: Shows a list of information
• BigPictureStyle
: Shows an image
Larger size: Jelly Bean notifications can be as tall as 256 dp.
Figure 14-4: Custom notifications in Jelly Bean.
These features aren’t available on older devices, so you can’t use them in versions earlier than 4.1. To give your notifications more impact in Jelly Bean, visit http://developer.android.com/guide/topics/ui/notifiers/notifications.html
for more information.