Android Tutorial

(avery) #1

By : Ketan Bhimani


416 

Expanded status bar showing the icon, both text fields, and
the time of the notification.

Updating Notifications

You don’t want your application’s notifications piling up in the
notification bar. Therefore, you might want to reuse or update
notifications to keep the notification list manageable. For example,
there is no reason to keep a notification informing the user that the
application is downloading File X when you now want to send
another notification saying File X has finished downloading.
Instead, you can simply update the first notification with new
information.

When the notification identifiers match, the old notification is
updated. When a notification with matching identifier is posted, the
ticker text does not draw a second time. To show the user that
something has changed, you can use a counter. The value of the
number member variable of the Notification object tracks and
displays this. For instance, we can set it to the number 4, as shown
here: notify.number = 4;
Free download pdf