Don't interrupt the user to inform them of an error if it is possible for the application to recover from the error on its own without the user taking any action.
Don't create notifications that have no true notification content and merely advertise your app. A notification should provide useful, timely, new information and should not be used to merely launch an app.
Don't create superfluous notifications just to get your brand in front of users. Such notifications will only frustrate and likely alienate your audience. The best way to provide the user with a small amount of updated information and to keep them engaged with your application is to develop a widget that they can choose to place on their home screen.
Interacting With Notifications
Notifications are indicated by icons in the status bar and can be accessed by opening the notification drawer.
Touching a notification opens the associated app to detailed content matching the notification. Swiping left or right on a notification removes it from the list.
Ongoing notifications
Ongoing notifications keep users informed about an ongoing process in the background. For example, music players announce the currently playing track in the notification system and continue to do so until the user stops the playback. They can also be used to show the user feedback for longer tasks like downloading a file, or encoding a video. Ongoing notifications cannot be manually removed from the notification drawer.
The L lockscreen doesn't show transport controls for RCC (Remote Control Client)s anymore. But the lockscreen does how notifications, so each app's playback notification is now the primary way for users to control playback from a locked state. This gives apps more control over which buttons to show and in what way, while providing a consistent experience for the user whether on the lockscreen or unlocked.
Dialogs and toasts are for feedback not notifications
Your app should not create a dialog or toast if it is not currently on screen. Dialogs and Toasts should only be displayed as the immediate response to the user taking an action inside of your app. For further guidance on the use of dialogs and toasts, refer to Confirming & Acknowledging.
Ranking and Ordering
Notifications are "news" and so they are essentially shown in reverse-chronological order, with special consideration given to the app's stated notification priority.
In L, notifications are now a key part of the lockscreen, and are featured prominently every time the device display comes on. Because space on the lockscreen is tight, it is more important than ever to identify the most urgent or relevant notifications.
Therefore, L has a more sophisticated sorting algorithm for notifications, taking into account:
The timestamp and application's stated priority, as before.
Whether the notification has recently disturbed the user with sound or vibration. (That is, if the phone just made noise, and the user wants to know "what just happened?" the lockscreen should answer that at a glance.)
Any people that are attached to the notification using EXTRA_PEOPLE, and in particular whether those are starred contacts.
To best take advantage of this sorting, developers should focus on the user experience they want to create rather than aiming for any particular spot on the list.
On the lockscreen
Starting in L, notifications are visible on the lockscreen, and so we must consider the user's privacy. Notifications often contain sensitive information, and we must take care when showing it to anyone who picks up the device and turns on the display.
For devices without a secure lockscreen, a simple slide gesture unlocks the whole device. Therefore, Android will always show the complete contents of all notifications on insecure lockscreens. Android系统英文文献和中文翻译(5):http://www.751com.cn/fanyi/lunwen_28864.html