RJB
RJB

Reputation: 1904

Android notification show full title and text

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.

Like this, enter image description here

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

Answers (1)

RJB
RJB

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

Related Questions