1 page.title=Notifications 2 @jd:body 3 4 <p>The notification system allows your app to keep the user informed about important events, such as 5 new messages in a chat app or a calendar event.</p> 6 <p>To create an app that feels streamlined, pleasant, and respectful, it is important to design your 7 notifications carefully. Notifications embody your app's voice, and contribute to your app's 8 personality. Unwanted or unimportant notifications can annoy the user, so use them judiciously.</p> 9 <h4>When to display a notification</h4> 10 <p>To create an application that people love, it's important to recognize that the user's attention and 11 focus is a resource that must be protected. To use an analogy that might resonate with software 12 developers, the user is not a method that can be invoked to return a value. The user's focus is a 13 resource more akin to a thread, and creating a notification momentarily blocks the user thread as 14 they process and then dismiss the interruptive notification.</p> 15 <p>Android's notification system has been designed to quickly inform users of events while they focus 16 on a task, but it is nonetheless still important to be conscientious when deciding to create a 17 notification.</p> 18 <p>While well behaved apps generally only speak when spoken to, there are some limited cases where an 19 app actually should interrupt the user with an unprompted notification.</p> 20 <p>Notifications should be used primarily for <strong>time sensitive events</strong>, and especially if these 21 synchronous events <strong>involve other people</strong>. For instance, an incoming chat is a real time and 22 synchronous form of communication: there is another user actively waiting on you to respond. 23 Calendar events are another good example of when to use a notification and grab the user's 24 attention, because the event is imminent, and calendar events often involve other people.</p> 25 26 <img src="{@docRoot}design/media/notifications_pattern_real_time_people.png"> 27 28 <div class="vspace size-2"> </div> 29 30 <div class="layout-content-row"> 31 <div class="layout-content-col span-7"> 32 33 <h4>When not to display a notification</h4> 34 <p>There are however many other cases where notifications should not be used:</p> 35 <ul> 36 <li> 37 <p>Don't notify the user of information that is not directed specifically at them, or information 38 that is not truly time sensitive. For instance the asynchronous and undirected updates flowing 39 through a social network do not warrant a real time interruption.</p> 40 </li> 41 <li> 42 <p>Don't create a notification if the relevant new information is currently on screen. Instead, use 43 the UI of the application itself to notify the user of new information directly in context. For 44 instance, a chat application should not create system notifications while the user is actively 45 chatting with another user.</p> 46 </li> 47 <li> 48 <p>Don't interrupt the user for low level technical operations, like saving or syncing information, 49 or updating an application, if it is possible for the system to simply take care of itself without 50 involving the user.</p> 51 </li> 52 <li> 53 <p>Don't interrupt the user to inform them of an error if it is possible for the application to 54 quickly recover from the error on its own without the user taking any action.</p> 55 </li> 56 <li> 57 <p>Don't use notifications for services that the user cannot manually start or stop.</p> 58 </li> 59 <li> 60 <p>Don't create superfluous notifications just to get your brand in front of users. Such 61 notifications will only frustrate and likely alienate your audience. The best way to provide the 62 user with a small amount of updated information and to keep them engaged with your application is to 63 develop a widget that they can choose to place on their home screen.</p> 64 </li> 65 </ul> 66 67 </div> 68 <div class="layout-content-col span-6"> 69 70 <img src="{@docRoot}design/media/notifications_pattern_social_fail.png"> 71 72 </div> 73 </div> 74 75 <h2 id="design-guidelines">Design Guidelines</h2> 76 77 <div class="layout-content-row"> 78 <div class="layout-content-col span-6"> 79 80 <img src="{@docRoot}design/media/notifications_pattern_anatomy.png"> 81 82 </div> 83 <div class="layout-content-col span-6"> 84 85 <h4>Make it personal</h4> 86 <p>For notifications of items sent by another user (such as a message or status update), include that 87 person's image.</p> 88 <p>Remember to include the app icon as a secondary icon in the notification, so that the user can 89 still identify which app posted it.</p> 90 91 </div> 92 </div> 93 94 <h4>Navigate to the right place</h4> 95 <p>When the user touches a notification, be open your app to the place where the user can consume and 96 act upon the data referenced in the notification. In most cases this will be the detail view of a 97 single data item (e.g. a message), but it might also be a summary view if the notification is 98 stacked (see <em>Stacked notifications</em> below) and references multiple items. If in any of those cases 99 the user is taken to a hierarchy level below your app's top-level, insert navigation into your app's 100 back stack to allow them to navigate to your app's top level using the system back key. For more 101 information, see the chapter on <em>System-to-app navigation</em> in the 102 <a href="{@docRoot}design/patterns/navigation.html">Navigation</a> design pattern.</p> 103 <h4>Timestamps for time sensitive events</h4> 104 <p>By default, standard Android notifications include a timestamp in the upper right corner. Consider 105 whether the timestamp is valuable in the context of your notification. If the timestamp is not 106 valuable, consider if the event is important enough to warrant grabbing the user's attention with a 107 notification. If the notification is important enough, decide if you would like to opt out of 108 displaying the timestamp.</p> 109 <p>Include a timestamp if the user likely needs to know how long ago the notification occurred. Good 110 candidates for timestamps include communication notifications (email, messaging, chat, voicemail) 111 where the user may need the timestamp information to understand the context of a message or to 112 tailor a response.</p> 113 <h4>Stack your notifications</h4> 114 <p>If your app creates a notification while another of the same type is still pending, avoid creating 115 an altogether new notification object. Instead, stack the notification.</p> 116 <p>A stacked notification builds a summary description and allows the user to understand how many 117 notifications of a particular kind are pending.</p> 118 <p><strong>Don't</strong>:</p> 119 120 <img src="{@docRoot}design/media/notifications_pattern_additional_fail.png"> 121 122 <p><strong>Do</strong>:</p> 123 124 <img src="{@docRoot}design/media/notifications_pattern_additional_win.png"> 125 126 <p>If you keep the summary and detail information on different screens, a stacked notification may need 127 to open to a different place in the app than a single notification.</p> 128 <p>For example, a single email notification should always open to the content of the email, whereas a 129 stacked email notification opens to the Inbox view.</p> 130 <h4>Clean up after yourself</h4> 131 <p>Just like calendar events, some notifications alert the user to an event that happens at a 132 particular point in time. After that moment has passed, the notification is likely not important to 133 the user anymore, and you should consider removing it automatically. The same is true for active 134 chat conversations or voicemail messages the user has listened to, users should not have to manually 135 dismiss notifications independently from taking action on them.</p> 136 137 <div class="vspace size-1"> </div> 138 139 <div class="layout-content-row"> 140 <div class="layout-content-col span-7"> 141 142 <h4>Provide a peek into your notification</h4> 143 <p>You can provide a short preview of your notification's content by providing optional ticker text. 144 The ticker text is shown for a short amount of time when the notification enters the system and then 145 hides automatically.</p> 146 147 </div> 148 <div class="layout-content-col span-6"> 149 150 <img src="{@docRoot}design/media/notifications_pattern_phone_ticker.png"> 151 152 </div> 153 </div> 154 155 <h4>Make notifications optional</h4> 156 <p>Users should always be in control of notifications. Allow the user to silence the notifications from 157 your app by adding a notification settings item to your application settings.</p> 158 <h4>Use distinct icons</h4> 159 <p>By glancing at the notification area, the user should be able to discern what notification types are 160 currently pending.</p> 161 <p><strong>Do</strong>:</p> 162 <ul> 163 <li>Look at the notification icons the Android apps already provide and create notification icons for 164 your app that are sufficiently distinct in appearance.</li> 165 </ul> 166 <p><strong>Don't</strong>:</p> 167 <ul> 168 <li>Use color to distinguish your app from others. Notification icons should generally be monochrome.</li> 169 </ul> 170 171 <h2 id="interacting-with-notifications">Interacting With Notifications</h2> 172 173 <div class="layout-content-row"> 174 <div class="layout-content-col span-6"> 175 176 <img src="{@docRoot}design/media/notifications_pattern_phone_icons.png"> 177 178 </div> 179 <div class="layout-content-col span-6"> 180 181 <p>Notifications are indicated by icons in the notification area and can be accessed by opening the 182 notification drawer.</p> 183 <p>Inside the drawer, notifications are chronologically sorted with the latest one on top. Touching a 184 notification opens the associated app to detailed content matching the notification. Swiping left or 185 right on a notification removes it from the drawer.</p> 186 187 </div> 188 </div> 189 190 <div class="layout-content-row"> 191 <div class="layout-content-col span-6"> 192 193 <p>On tablets, the notification area is integrated with the system bar at the bottom of the screen. The 194 notification drawer is opened by touching anywhere inside the notification area.</p> 195 196 </div> 197 <div class="layout-content-col span-6"> 198 199 <img src="{@docRoot}design/media/notifications_pattern_tablet.png"> 200 201 </div> 202 </div> 203 204 <div class="layout-content-row"> 205 <div class="layout-content-col span-6"> 206 207 <img src="{@docRoot}design/media/notifications_pattern_ongoing_music.png"> 208 209 </div> 210 <div class="layout-content-col span-6"> 211 212 <h4>Ongoing notifications</h4> 213 <p>Ongoing notifications keep users informed about an ongoing process in the background. For example, 214 music players announce the currently playing track in the notification system and continue to do so 215 until the user stops the playback. They can also be used to show the user feedback for longer tasks 216 like downloading a file, or encoding a video. Ongoing notifications cannot be manually removed from 217 the notification drawer.</p> 218 219 </div> 220 </div> 221 222 <div class="layout-content-row"> 223 <div class="layout-content-col span-12"> 224 225 <h4>Dialogs and toasts are for feedback not notification</h4> 226 <p>Your app should not create a dialog or toast if it is not currently on screen. Dialogs and Toasts 227 should only be displayed as the immediate response to the user taking an action inside of your app. 228 For instance, dialogs can be used to confirm that the user understands the severity of an action, 229 and toasts can echo back that an action has been successfully taken.</p> 230 231 </div> 232 </div> 233 234 <div class="vspace size-1"> </div> 235 236 <img src="{@docRoot}design/media/notifications_pattern_dialog_toast.png"> 237