Reputation: 1904
I am trying to create a simple notification. With this code, the notification appears as an icon in the notification area, and when I open up the notification drawer it is there...
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
mBuilder.setSmallIcon(R.drawable.midday);
mBuilder.setContentTitle("Midday");
mBuilder.setContentText("Now it is midday");
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
I want this notification content to actually show on the top of the screen, not just that the little icon appear on the top bar.
I tried searching for this and found that...
mBuilder.setPriority(NotificationCompat.PRIORITY_HIGH);
should help. But it didn't show the notification, only the little icon appears.
If you can help, that would be great.
Upvotes: 3
Views: 4774
Reputation: 1904
This is the answer:
Its called a Heads-up Notifications.
This should be enough:
mBuilder.setPriority(NotificationCompat.PRIORITY_HIGH);
However, I have to add this line:
mBuilder.setDefaults(Notification.DEFAULT_VIBRATE);
Hopefully google will fix this
Upvotes: 1