Mobile App Development Tutorial For Creating Android Notification Using NotificationCompat


1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 5.00 out of 5)



In Android, creating a notification and displaying it in the notification area is a popular feature in every application. A notification has many styles and configurations available for the developer during its setup.  However, the styles and configurations available on every version of Android is different. To the extent, it becomes a difficult task for developers to create styles and configurations correctly to fit every Android version. Fortunately, NotificationCompat is here to save the day.


Tung Dao Xuan,, is the author of this article and he contributes to RobustTechHouse Blog


Using NotificationCompat

– Create a normal notification

To create a notification we will use NotificationCompat.Builder class.


Once you have the Builder object, you can set Notification properties using the Builder object according to your requirements.

A Notification object must contain the following:

  • A small icon, set by setSmallIcon()
  • A title, set by setContentTitle()
  • Detailed text, set by setContentText()

After your notification is created, you can apply it to the notification area using NotificationManagerCompat


– Create a notification with action

An action allows users to go directly from the notification to an Activity in your application where they can look at more events or do further work.


You can also add buttons to the notification that perform additional actions such as: to postpone a task or response immediately to a task. This feature is available from Android 4.1 onwards.


– Create a notification with style

Notification.Style was introduced in Android 4.1, which are not supported on older devices.

There are some styles as the following:

Notification.BigPictureStyle Helper class for generating large-format notifications that include a large image attachment.
Notification.BigTextStyle Helper class for generating large-format notifications that include a lot of text.
Notification.InboxStyle Helper class for generating large-format notifications that include a list of (up to 5) strings.
Notification.MediaStyle Notification style for media playback notifications.


The following  codes  demonstrate how notification is set up using InboxStyle:


Setting up a notification with other styles is very similar to InboxStyle, (as shown above). However, compatibility with Notification.MediaStyle requires us to use NotificationCompat in android support v7 (



This tutorial deliberately chose to highlight a few main features of NotificationCompat. There are in fact many other features waiting to be explored and to  help make your life easier. If you are interested, you can find out more in the following website:


Source code


Brought to you by the RobustTechHouse team (A top iOS and Android developer in Singapore).  If you like our articles, please also check out our Facebook page.

Recommended Posts
Contact Us

We look forward to your messages. Please drop us a note for any enquiries and we'll get back to you, asap.

Not readable? Change text. captcha txt