I am working on the notification and I want to have a "head-up" notification (Highlighted in Purple) similar to "Cal" app, which is shown in the picture below. The app called this notification as "Head-up" notification, but I don't know if this is the correct name or not. It would be great if anyone would share how to create this feature programmatically on Android. Thanks!
-
You can add a RelativeLayout with a Canvas anywhere on the screen... What have you tried to implement the feature? – OneCricketeer Jun 28 '16 at 02:15
-
Do you have any examples to show me? For this "head-up" notification, when you click on the box, it will launch the app and go to the event detail page. It is more than a layout on the screen. For the normal notification, we still have the notification manager to handle it, i just want to know the official name for this type of ui. If i know the name, then i will try to look for the way to create it. – Antoine Murion Jun 28 '16 at 03:17
-
I don't have examples or a name. That image is a custom widget on the home screen. All Views in Android essentially draw themselves within a rectangle. All you have to do is create a new `Canvas` or `View` object and draw on it after making it visible in the parent layout – OneCricketeer Jun 28 '16 at 03:22
1 Answers
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]);
To create custom layout for heads up notification, refer this link. In lollipop the notification has a new field named headsupContentView. use your custom remoteview, set to headsupContentView(). it can be change.
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.

- 1
- 1

- 436
- 1
- 3
- 14