1page.title=Notifications, Android 4.4 and Lower
2footer.hide=1
3@jd:body
4
5<a class="notice-developers right" href="{@docRoot}training/notify-user/index.html">
6  <div>
7    <h3>Developer Docs</h3>
8    <p>Notifying the User</p>
9  </div>
10</a>
11
12<a class="notice-designers right" href="notifications.html">
13  <div>
14    <h3>Notifications in Android 5.0</h3>
15  </div>
16</a>
17
18<p itemprop="description">The notification system allows your app to keep the
19user informed about events, such as new chat messages or a calendar event.
20Think of notifications as a news channel that alerts the user to important
21events as they happen or a log that chronicles events while the user is not
22paying attention.</p>
23
24<h2>Anatomy of a notification</h2>
25
26<div class="cols">
27  <div class="col-6">
28    <h4>Base Layout</h4>
29    <p>At a minimum, all notifications consist of a base layout, including:</p>
30    <ul>
31      <li>the sending application's notification icon or the sender's photo</li>
32      <li>a notification title and message</li>
33      <li>a timestamp</li>
34      <li>a secondary icon to identify the sending application when the sender's
35image is shown for the main icon</li>
36    </ul>
37  </div>
38  <div class="col-6">
39    <img src="{@docRoot}design/media/notifications_pattern_anatomy.png">
40    <div class="figure-caption">
41      Base layout of a notification
42    </div>
43  </div>
44</div>
45
46<h4>Expanded layouts</h4>
47<p>You have the option to provide more event detail. You can use this to show
48the first few lines of a message or show a larger image preview. This provides
49the user with additional context, and - in some cases - may allow the user to
50read a message in its entirety. The user can pinch-zoom or two-finger glide in
51order to toggle between base and expanded layouts. For single event
52notifications, Android provides two expanded layout templates (text and image)
53for you to re-use in your application.</p>
54
55<img src="{@docRoot}design/media/notifications_pattern_expandable.png">
56
57<h4>Actions</h4>
58<div class="cols">
59  <div class="col-6">
60    <p>Android supports optional actions that are displayed at the bottom of
61the notification. With actions, users can handle the most common tasks for a
62particular notification from within the notification shade without having to
63open the originating application. This speeds up interaction and, in
64conjunction with "swipe-to-dismiss", helps users to streamline their
65notification triaging experience.</p>
66    <p>Be judicious with how many actions you include with a notification. The
67more actions you include, the more cognitive complexity you create. Limit
68yourself to the fewest number of actions possible by only including the most
69imminently important and meaningful ones.</p>
70    <p>Good candidates for actions on notifications are actions that are:</p>
71    <ul>
72      <li>essential, frequent and typical for the content type you're
73displaying</li>
74      <li>time-critical</li>
75      <li>not overlapping with neighboring actions</li>
76    </ul>
77    <p>Avoid actions that are:</p>
78    <ul>
79      <li>ambiguous</li>
80      <li>duplicative of the default action of the notification (such as "Read"
81or "Open")</li>
82    </ul>
83  </div>
84  <div class="col-7">
85    <img src="{@docRoot}design/media/notifications_pattern_two_actions.png">
86    <div class="figure-caption">
87      Calendar reminder notification with two actions
88    </div>
89  </div>
90</div>
91
92<p>You can specify a maximum of three actions, each consisting of an action
93icon and an action name. Adding actions to a simple base layout will make the
94notification expandable, even if the notification doesn't have an expanded
95layout. Since actions are only shown for expanded notifications and are
96otherwise hidden, you must make sure that any action a user can invoke from a
97notification is available from within the associated application as well.</p>
98
99<h2>Design guidelines</h2>
100<div class="cols">
101  <div class="col-6">
102    <img src="{@docRoot}design/media/notifications_pattern_personal.png">
103  </div>
104  <div class="col-7">
105    <h4>Make it personal</h4>
106    <p>For notifications of items sent by another user (such as a message or
107status update), include that person's image.</p>
108    <p>Remember to include the app icon as a secondary icon in the
109notification, so that the user can still identify which app posted it.</p>
110  </div>
111</div>
112
113<h4>Navigate to the right place</h4>
114<p>When the user touches the body of a notification (outside of the action
115buttons), open your app to the place where the user can consume and act upon
116the data referenced in the notification. In most cases this will be the detail
117view of a
118single data item such as a message, but it might also be a summary view if the
119notification is stacked (see <em>Stacked notifications</em> below) and
120references multiple items. If in any of those cases the user is taken to a
121hierarchy level below your app's top-level, insert navigation into your app's
122back stack to allow them to navigate to your app's top level using the system
123back key. For more
124information, see the chapter on <em>System-to-app navigation</em> in the <a
125href="{@docRoot}design/patterns/navigation.html">Navigation</a> design
126pattern.</p>
127
128<h4>Correctly set and manage notification priority</h4>
129<p>Starting with Jelly Bean, Android supports a priority flag for
130notifications. This flag allows you to influence where your notification will
131appear in comparison to other notifications and help to make sure that users
132always see their most important notifications first. You can choose from the
133following priority levels when posting a notification:</p>
134
135<table>
136  <tr>
137    <th><strong>Priority</strong></th>
138    <th><strong>Use</strong></th>
139  </tr>
140  <tr>
141    <td>MAX</td>
142    <td>Use for critical and urgent notifications that alert the user to a
143condition that is time-critical or needs to be resolved before they can
144continue with a particular task.</td>
145  </tr>
146  <tr>
147    <td>HIGH</td>
148    <td>Use high priority notifications primarily for important communication,
149such as message or chat events with content that is particularly interesting
150for the user.</td>
151  </tr>
152  <tr>
153    <td>DEFAULT</td>
154    <td>The default priority. Keep all notifications that don't fall into any
155of the other categories at this priority level.</td>
156  </tr>
157  <tr>
158    <td>LOW</td>
159    <td>Use for notifications that you still want the user to be informed
160about, but that rate low in urgency.</td>
161  </tr>
162  <tr>
163    <td>MIN</td>
164    <td>Contextual/background information (e.g. weather information, contextual
165location information). Minimum     priority notifications will not show in the
166status bar. The user will only discover them when they expand the notification
167tray.</td>
168  </tr>
169</table>
170<img src="{@docRoot}design/media/notifications_pattern_priority.png">
171
172<h4>Stack your notifications</h4>
173<p>If your app creates a notification while another of the same type is still
174pending, avoid creating
175an altogether new notification object. Instead, stack the notification.</p>
176<p>A stacked notification builds a summary description and allows the user to
177understand how many
178notifications of a particular kind are pending.</p>
179<p><strong>Don't</strong>:</p>
180
181<img src="{@docRoot}design/media/notifications_pattern_additional_fail.png">
182
183<p><strong>Do</strong>:</p>
184
185<img src="{@docRoot}design/media/notifications_pattern_additional_win.png">
186
187<p>You can provide more detail about the individual notifications that make up
188a stack by using the expanded digest layout. This allows users to gain a better
189sense of which notifications are pending and if they are interesting enough to
190be read in detail within the associated app.</p>
191
192<img src="{@docRoot}design/media/notifications_expand_contract_msg.png">
193
194<h4>Make notifications optional</h4>
195<p>Users should always be in control of notifications. Allow the user to
196disable your apps notifications or change their alert properties, such as alert
197sound and whether to use vibration, by adding a notification settings item to
198your application settings.</p>
199<h4>Use distinct icons</h4>
200<p>By glancing at the notification area, the user should be able to discern
201what kinds of notifications are currently pending.</p>
202
203<div class="do-dont-label good"><strong>Do</strong></div>
204<p style="margin-top:0;">Look at the notification icons the Android apps
205already provide and create notification icons for your app that are
206sufficiently distinct in appearance.</p>
207<div class="do-dont-label good"><strong>Do</strong></div>
208<p style="margin-top:0;">Use the proper <a
209href="{@docRoot}design/style/iconography.html#notification">notification icon
210style</a> for small icons, and the Holo Dark <a
211href="{@docRoot}design/style/iconography.html#action-bar">action bar icon
212style</a> for your action icons.</p>
213<div class="do-dont-label good"><strong>Do</strong></div>
214<p style="margin-top:0;">Keep your icons visually simple and avoid excessive
215detail that is hard to discern.</p>
216<div class="do-dont-label bad"><strong>Don't</strong></div>
217<p style="margin-top:0;">Use color to distinguish your app from others.</p>
218
219<h4>Pulse the notification LED appropriately</h4>
220<p>Many Android devices contain a tiny lamp, called the notification <acronym
221title="Light-Emitting Diode">LED</acronym>, which is used to keep the user
222informed about events while the screen is off. Notifications with a priority
223level of MAX, HIGH, or DEFAULT should cause the LED to glow, while those with
224lower priority (LOW and MIN) should not.</p>
225
226<p>The user's control over notifications should extend to the LED. By default,
227the LED will glow with a white color. Your notifications shouldn't use a
228different color unless the user has explicitly customized it.</p>
229
230<h2>Building notifications that users care about</h2>
231<p>To create an app that feels streamlined, pleasant, and respectful, it is
232important to design your notifications carefully. Notifications embody your
233app's voice, and contribute to your app's personality. Unwanted or unimportant
234notifications can annoy the user, so use them judiciously.</p>
235
236<h4>When to display a notification</h4>
237<p>To create an application that people love, it's important to recognize that
238the user's attention and
239focus is a resource that must be protected. While Android's notification system
240has been designed
241to minimize the impact of notifications on the users attention, it is
242nonetheless still important
243to be aware of the fact that notifications are potentially interrupting the
244users task flow. As you
245plan your notifications, ask yourself if they are important enough to warrant
246an interruption. If
247you are unsure, allow the user to opt into a notification using your apps
248notification settings or
249adjust the notifications priority flag.</p>
250<p>While well behaved apps generally only speak when spoken to, there are some
251limited cases where an
252app actually should interrupt the user with an unprompted notification.</p>
253<p>Notifications should be used primarily for <strong>time sensitive
254events</strong>, and especially if these
255synchronous events <strong>involve other people</strong>. For instance, an
256incoming chat is a real time and
257synchronous form of communication: there is another user actively waiting on
258you to respond.
259Calendar events are another good example of when to use a notification and grab
260the user's
261attention, because the event is imminent, and calendar events often involve
262other people.</p>
263
264<img src="{@docRoot}design/media/notifications_pattern_real_time_people.png">
265
266<div class="vspace size-2">&nbsp;</div>
267
268<div class="cols">
269  <div class="col-7">
270
271<h4>When not to display a notification</h4>
272<p>There are however many other cases where notifications should not be
273used:</p>
274<ul>
275<li>
276<p>Avoid notifying the user of information that is not directed specifically at
277them, or information that is not truly time sensitive. For instance the
278asynchronous and undirected updates flowing through a social network generally
279do not warrant a real time interruption. For the users that do care about them,
280allow them to opt-in.</p>
281</li>
282<li>
283<p>Don't create a notification if the relevant new information is currently on
284screen. Instead, use the UI of the application itself to notify the user of new
285information directly in context. For instance, a chat application should not
286create system notifications while the user is actively chatting with another
287user.</p>
288</li>
289<li>
290<p>Don't interrupt the user for low level technical operations, like saving or
291syncing information, or updating an application, if it is possible for the
292system to simply take care of itself without involving the user.</p>
293</li>
294<li>
295<p>Don't interrupt the user to inform them of an error if it is possible for
296the application to quickly recover from the error on its own without the user
297taking any action.</p>
298</li>
299<li>
300<p>Don't create notifications that have no true notification content and merely
301advertise your app. A notification should inform the user about a state and
302should not be used to merely launch an app.</p>
303</li>
304<li>
305<p>Don't create superfluous notifications just to get your brand in front of
306users. Such
307notifications will only frustrate and likely alienate your audience. The best
308way to provide the
309user with a small amount of updated information and to keep them engaged with
310your application is to
311develop a widget that they can choose to place on their home screen.</p>
312</li>
313</ul>
314
315  </div>
316  <div class="col-6">
317    <img src="{@docRoot}design/media/notifications_pattern_social_fail.png">
318  </div>
319</div>
320
321<h2 id="interacting-with-notifications">Interacting With Notifications</h2>
322
323<div class="cols">
324  <div class="col-6">
325
326    <img src="{@docRoot}design/media/notifications_pattern_phone_icons.png">
327
328  </div>
329  <div class="col-6">
330
331  <p>Notifications are indicated by icons in the notification area and can be
332accessed by opening the notification drawer.</p>
333  <p>Inside the drawer, notifications are chronologically sorted with the
334latest one on top. Touching a notification opens the associated app to detailed
335content matching the notification. Swiping left or right on a notification
336removes it from the drawer.</p>
337
338  </div>
339</div>
340
341<div class="cols">
342  <div class="col-6">
343
344<p><h4>Ongoing notifications</h4>
345<p>Ongoing notifications keep users informed about an ongoing process in the
346background. For example, music players announce the currently playing track in
347the notification system and continue to do so until the user stops the
348playback. They can also be used to show the user feedback for longer tasks like
349downloading a file, or encoding a video. Ongoing notifications cannot be
350manually removed from the notification drawer.</p></p>
351
352  </div>
353  <div class="col-6">
354
355    <img src="{@docRoot}design/media/notifications_pattern_ongoing_music.png">
356
357  </div>
358</div>
359
360<div class="cols">
361  <div class="col-12">
362    <h4>Dialogs and toasts are for feedback not notification</h4>
363    <p>Your app should not create a dialog or toast if it is not currently on
364screen. Dialogs and Toasts should only be displayed as the immediate response
365to the user taking an action inside of your app. For further guidance on the
366use of dialogs and toasts, refer to <a
367href="{@docRoot}design/patterns/confirming-acknowledging.html">Confirming &amp;
368Acknowledging</a>.</p>
369  </div>
370</div>
371