Amelia@Amazon avatar image
Amelia@Amazon posted

Using Notification.Builder to create app notifications   


Every single device that runs Android has a notification bar on the top of the screen, and it is used as a quick way for an app to give information to the user outside of the application's actual interface. After being sent, it will first appear as an icon in the navigation bar, and users can access it by simply dragging down the drawer and either pressing it (usually taking the user to the app in question), or as with recent versions of Android, swiping it away and removing it. You can even add small commands such as pausing or rewinding music from the notification.

For more information on notifications in Android from a technical perspective, see here:

From a design perspective, it's recommended to go here:


It's suggested to check out the design documentation due to the recent changes to notifications in Android L (5.0, API 21). As listed in the above link, the 4 main changes include:

The new material design theme - Devices running Android L are visibly very different to previous versions of Android using the new 'material' design, and it's suggested to accomodate this even with notifications. See here for more info: -

Lock screen notifications - If a user has an unopened notifcation, this can now appear on their lock screen, rather than them having to unlock their device to see it. This is great from a usability perspective as it doesn't insist on the user spending more time on the phone (ie. waking it up, unlocking it, dragging down the notification drawer) to see their notifications; even better, sensitive information can still be hidden, so this doesn't mean that private information will still be displayed regardless (great for hiding info if the device has been stolen/lost).

Heads-up notifications - These are more interactive notifications (usually high priority) that allow users to interact with them where ever they are on the device without touching the notification bar via an actual 'pop up' at the top of the screen.

Cloud-synced notifications - Dismissing the notification on one Android device will dismiss it on all of the user's android devices To create a notification, Notification.Builder is a builder class that allows easy assignment of various fields for a notification. As stated, a user can interact with an app without using it's actual UI, so users can carry on doing other things on their device. For more information, see here:

Notification notificationExample = new Notification.Builder(mContext)
    .setContentTitle("New mail from " + sender.toString())
//A simple notification from the Android documentation that will notify the user about new mail

Keywords: Notifications, Code, Material Design


10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.



rossbria contributed to this article brizzlebrazzle contributed to this article