Home | History | Annotate | Download | only in patterns
      1 page.title=Notifications, Android 4.4 and Lower
      2 footer.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
     19 user informed about events, such as new chat messages or a calendar event.
     20 Think of notifications as a news channel that alerts the user to important
     21 events as they happen or a log that chronicles events while the user is not
     22 paying 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
     35 image 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
     48 the first few lines of a message or show a larger image preview. This provides
     49 the user with additional context, and - in some cases - may allow the user to
     50 read a message in its entirety. The user can pinch-zoom or two-finger glide in
     51 order to toggle between base and expanded layouts. For single event
     52 notifications, Android provides two expanded layout templates (text and image)
     53 for 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
     61 the notification. With actions, users can handle the most common tasks for a
     62 particular notification from within the notification shade without having to
     63 open the originating application. This speeds up interaction and, in
     64 conjunction with "swipe-to-dismiss", helps users to streamline their
     65 notification triaging experience.</p>
     66     <p>Be judicious with how many actions you include with a notification. The
     67 more actions you include, the more cognitive complexity you create. Limit
     68 yourself to the fewest number of actions possible by only including the most
     69 imminently 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
     73 displaying</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"
     81 or "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
     93 icon and an action name. Adding actions to a simple base layout will make the
     94 notification expandable, even if the notification doesn't have an expanded
     95 layout. Since actions are only shown for expanded notifications and are
     96 otherwise hidden, you must make sure that any action a user can invoke from a
     97 notification 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
    107 status update), include that person's image.</p>
    108     <p>Remember to include the app icon as a secondary icon in the
    109 notification, 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
    115 buttons), open your app to the place where the user can consume and act upon
    116 the data referenced in the notification. In most cases this will be the detail
    117 view of a
    118 single data item such as a message, but it might also be a summary view if the
    119 notification is stacked (see <em>Stacked notifications</em> below) and
    120 references multiple items. If in any of those cases the user is taken to a
    121 hierarchy level below your app's top-level, insert navigation into your app's
    122 back stack to allow them to navigate to your app's top level using the system
    123 back key. For more
    124 information, see the chapter on <em>System-to-app navigation</em> in the <a
    125 href="{@docRoot}design/patterns/navigation.html">Navigation</a> design
    126 pattern.</p>
    127 
    128 <h4>Correctly set and manage notification priority</h4>
    129 <p>Starting with Jelly Bean, Android supports a priority flag for
    130 notifications. This flag allows you to influence where your notification will
    131 appear in comparison to other notifications and help to make sure that users
    132 always see their most important notifications first. You can choose from the
    133 following 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
    143 condition that is time-critical or needs to be resolved before they can
    144 continue with a particular task.</td>
    145   </tr>
    146   <tr>
    147     <td>HIGH</td>
    148     <td>Use high priority notifications primarily for important communication,
    149 such as message or chat events with content that is particularly interesting
    150 for 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
    155 of 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
    160 about, 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
    165 location information). Minimum     priority notifications will not show in the
    166 status bar. The user will only discover them when they expand the notification
    167 tray.</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
    174 pending, avoid creating
    175 an altogether new notification object. Instead, stack the notification.</p>
    176 <p>A stacked notification builds a summary description and allows the user to
    177 understand how many
    178 notifications 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
    188 a stack by using the expanded digest layout. This allows users to gain a better
    189 sense of which notifications are pending and if they are interesting enough to
    190 be 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
    196 disable your apps notifications or change their alert properties, such as alert
    197 sound and whether to use vibration, by adding a notification settings item to
    198 your application settings.</p>
    199 <h4>Use distinct icons</h4>
    200 <p>By glancing at the notification area, the user should be able to discern
    201 what 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
    205 already provide and create notification icons for your app that are
    206 sufficiently 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
    209 href="{@docRoot}design/style/iconography.html#notification">notification icon
    210 style</a> for small icons, and the Holo Dark <a
    211 href="{@docRoot}design/style/iconography.html#action-bar">action bar icon
    212 style</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
    215 detail 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
    221 title="Light-Emitting Diode">LED</acronym>, which is used to keep the user
    222 informed about events while the screen is off. Notifications with a priority
    223 level of MAX, HIGH, or DEFAULT should cause the LED to glow, while those with
    224 lower priority (LOW and MIN) should not.</p>
    225 
    226 <p>The user's control over notifications should extend to the LED. By default,
    227 the LED will glow with a white color. Your notifications shouldn't use a
    228 different 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
    232 important to design your notifications carefully. Notifications embody your
    233 app's voice, and contribute to your app's personality. Unwanted or unimportant
    234 notifications 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
    238 the user's attention and
    239 focus is a resource that must be protected. While Android's notification system
    240 has been designed
    241 to minimize the impact of notifications on the users attention, it is
    242 nonetheless still important
    243 to be aware of the fact that notifications are potentially interrupting the
    244 users task flow. As you
    245 plan your notifications, ask yourself if they are important enough to warrant
    246 an interruption. If
    247 you are unsure, allow the user to opt into a notification using your apps
    248 notification settings or
    249 adjust the notifications priority flag.</p>
    250 <p>While well behaved apps generally only speak when spoken to, there are some
    251 limited cases where an
    252 app actually should interrupt the user with an unprompted notification.</p>
    253 <p>Notifications should be used primarily for <strong>time sensitive
    254 events</strong>, and especially if these
    255 synchronous events <strong>involve other people</strong>. For instance, an
    256 incoming chat is a real time and
    257 synchronous form of communication: there is another user actively waiting on
    258 you to respond.
    259 Calendar events are another good example of when to use a notification and grab
    260 the user's
    261 attention, because the event is imminent, and calendar events often involve
    262 other 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
    273 used:</p>
    274 <ul>
    275 <li>
    276 <p>Avoid notifying the user of information that is not directed specifically at
    277 them, or information that is not truly time sensitive. For instance the
    278 asynchronous and undirected updates flowing through a social network generally
    279 do not warrant a real time interruption. For the users that do care about them,
    280 allow them to opt-in.</p>
    281 </li>
    282 <li>
    283 <p>Don't create a notification if the relevant new information is currently on
    284 screen. Instead, use the UI of the application itself to notify the user of new
    285 information directly in context. For instance, a chat application should not
    286 create system notifications while the user is actively chatting with another
    287 user.</p>
    288 </li>
    289 <li>
    290 <p>Don't interrupt the user for low level technical operations, like saving or
    291 syncing information, or updating an application, if it is possible for the
    292 system 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
    296 the application to quickly recover from the error on its own without the user
    297 taking any action.</p>
    298 </li>
    299 <li>
    300 <p>Don't create notifications that have no true notification content and merely
    301 advertise your app. A notification should inform the user about a state and
    302 should 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
    306 users. Such
    307 notifications will only frustrate and likely alienate your audience. The best
    308 way to provide the
    309 user with a small amount of updated information and to keep them engaged with
    310 your application is to
    311 develop 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
    332 accessed by opening the notification drawer.</p>
    333   <p>Inside the drawer, notifications are chronologically sorted with the
    334 latest one on top. Touching a notification opens the associated app to detailed
    335 content matching the notification. Swiping left or right on a notification
    336 removes 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
    346 background. For example, music players announce the currently playing track in
    347 the notification system and continue to do so until the user stops the
    348 playback. They can also be used to show the user feedback for longer tasks like
    349 downloading a file, or encoding a video. Ongoing notifications cannot be
    350 manually 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
    364 screen. Dialogs and Toasts should only be displayed as the immediate response
    365 to the user taking an action inside of your app. For further guidance on the
    366 use of dialogs and toasts, refer to <a
    367 href="{@docRoot}design/patterns/confirming-acknowledging.html">Confirming &amp;
    368 Acknowledging</a>.</p>
    369   </div>
    370 </div>
    371