Published November 17, 2016

Notifications: From zero to hero Android N* – part 3/3

Android Nougat is here and it’s time to learn how to set up the notifications in this version of the system. The bundled notifications and the possibility of replying to them made them even more useful!

The final article of “Notifications: From zero to hero Android N*” series guides you through Android N. In case you missed the previous ones, here you go:

1. If you are a newbie to the Android notifications, here are the very essentials you need to know to build them for the Android Platform. Including the definition itself, just to let you start the proper way.

2. A notifications guide for all developers who already got the basics. You will learn how to become a pro of the Android notifications. It covers Android 5 and 6.

1. Replying to notifications

Sometimes opening the whole app to the user so that he/she could react to the notification can be an overkill. To avoid that kind of situations, users can now respond to the notifications directly (starting in Android 7.0).

To make this happen, first, we have to use RemoteInput.Builder which will be used to extract the text input from the user.

Secondly, we need to specify an action which will be triggered after user’s response (in this example we are going to start the IntentService instance to handle the response).

And then we trigger the notification.

The last thing to do is to handle the input from the user.


2. Bundled notifications

Another cool feature introduced in Android N are bundled notifications. It means that you can now group your messages by their type (consider for example a list of received email messages).


The important part here are the methods:

  • setGroupSummary(true) – Used for the first notification. This “summary” message won’t appear in the group and it will be the only notification on the devices with older Androids
  • setGroup(GROUP_KEY) – This is how you group the notifications together



3. Styling notifications

Starting from Android N there are also new styling types available.

3.1 Styling conversations

MessagingStyle can be used for conversation-like notifications, like in the example below.


  • setColor(getColor(R.color.colorAccent)) – this method is available since Lollipop and it will color our notification
  • new Notification.MessagingStyle("Me") – text passed to the constructor will be colored and used in the message with null passed as a sender (it will appear as a sender of the notification)



3.2 Styling remote views

DecoratedCustomViewStyle is most definitely another cool styling option. It helps in obtaining system decorations while using custom layouts with RemoteViews.



See how bad it looks without Without DecoratedCustomViewStyle


All examples from this article are available on Github page NotificationsDemo