How to Get Heads Up notifications in Android
Android Lollipop brings lots of good things for devices. One of the most useful thing is to make design attractive with animation by material design, along with that it also introduce a new type of notification which is known as “Heads-up” notification.
When device gets high-priority notification, it think like as floating window notifications that appear at the top of the screen and will presented to user for short period of time with expanded layout and exposing possible actions. You can either tap them to open them or swipe them away to dismiss them. This type of of notification appears only when the device is active (that is, the device is unlocked and its screen is on).
Heads-up Notification will alerts user on incoming phone call, alarm, new message, low battery, calendar based events etc.
If Notification’s priority is flagged as High, Max, or full-screen, it gets a Heads-up notification. User can also configure priority modes from
Settings -> Sound & notification ->Interruptions
From here User can set all type of setting for Notification.
[ Note : Heads-up notifications introduce in Android lollipop and + version.]
Here is example code of Heads-up notification :
For more detail on Notification refer my previous blog Different Types Of Notification Android
NotificationCompat.Builder builder =
.setContentText("Tomorrow will be your birthday.")
.setDefaults(Notification.DEFAULT_ALL) // must requires VIBRATE permission
.setPriority(NotificationCompat.PRIORITY_HIGH) //must give priority to High, Max which will considered as heads-up notification
//set intents and pending intents to call service on click of "dismiss" action button of notification
Intent dismissIntent = new Intent(this, MyService.class);
PendingIntent piDismiss = PendingIntent.getService(this, 0, dismissIntent, 0);
//set intents and pending intents to call service on click of "snooze" action button of notification
Intent snoozeIntent = new Intent(this, MyService.class);
PendingIntent piSnooze = PendingIntent.getService(this, 0, snoozeIntent, 0);
// Gets an instance of the NotificationManager service
NotificationManager notificationManager =
//to post your notification to the notification bar with a id. If a notification with same id already exists, it will get replaced with updated information.
There is some issues with Heads-up Notification like as below:
- First, the “heads-up” card shows you only a tiny snippet of message-oriented notifications and provides no way to expand them and view their full contents without switching over to the source app (e.g. Hangouts, Gmail, or whatever is sending the alert).
- If you are in the middle of doing something else on your device and don’t want to deal with an incoming “heads-up” notification right away but you want to keep it around so you’ll remember to deal with it later but you have only choice to stop what you are doing and wait about 10 seconds until the card disappears, at which point it’ll move up into your notification panel as a regular alert. If you swipe the card away, the notification will get dismissed.
If you want to disable heads-up notification, there is not any official way but you can do by third party app which you can find in play store.
Brevity Software provides services such as : Web design and development, Mobile application development, Web application development, Travel portal development, Event management systems, Transport & Logistics Software, Enterprise Mobility Solutions, eCommerce & M Commerce application and many more.