Get Heads Up notifications
November 9, 2015 Julie raiyani 4 Comments

Android Lollipop brings lots of good things for devices. One of the most useful things is to make the design attractive with animation by material design, along with that it also introduces a new type of notification which is known as “Heads-up notification.

When the device gets a high-priority notification, it thinks like as floating window notifications that appear at the top of the screen and will be presented to the 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 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 were introduced in Android lollipop and + version.

Here is an example code of Heads-up notification :

[cc lang=”java”]//build notification
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setContentTitle(“Ping Notification”)
.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
getString(R.string.dismiss), piDismiss)
getString(R.string.snooze), piSnooze);

//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 =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

/* Notification for oreo*/

String channelId = “channel-01”;
String channelName = “Demo”;
int importance = NotificationManager.IMPORTANCE_HIGH;

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationChannel mChannel = new NotificationChannel(
channelId, channelName, importance);

//to post your notification to the notification bar with an id. If a notification with the same id already exists, it will get replaced with updated information.



There are some issues with Heads-up Notification like 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 a third-party app which you can find in play store.

4 People reacted on this

  1. Fantastic site. A lot of useful info here. I am sending it to a few friends ans also sharing in delicious. And naturally, thank you in your effort!

  2. It’s a great post. This site has lots of useful things, it really helped me in many ways.

Comments are closed.