Heads-up Notification – Android Lollipop

According to Notifications, you are required to set a vibrate or ringtone to make Heads-up work. However, here’s a quick hack that doesn’t require VIBRATE permission to produce a head-up notification:

notificationBuilder.setPriority(Notification.PRIORITY_HIGH);
if (Build.VERSION.SDK_INT >= 21) notificationBuilder.setVibrate(new long[0]);

EDIT:

Don’t abuse heads-up notification. See here for when to use heads-up notification:

MAX: For critical and urgent notifications that alert the user to a condition that is time-critical or needs to be resolved before they can continue with a particular task.

HIGH: Primarily for important communication, such as messages or chat events with content that is particularly interesting for the user. High-priority notifications trigger the heads-up notification display.

Leave a Comment