BigStyle notification not showing short texts

I am creating a Download-Notification and using the BigTextStyle of NotificationCompat because the text can be very long depends on how much you download.

The line of code I'm using:

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setSmallIcon(R.drawable.logo_24dp);

    String notifiactionTitle = res.getString(R.string.notification__download_successful_title);
    builder.setContentTitle(notifiactionTitle);    

      

and here I am setting the content text:

builder.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationMessage));

      

As a result, a notification is displayed if I use the message as long as "Items loaded: xy, x, y, xz, x, zy"

But not if I only have one item: "Loaded item: xy".

I tested that I can randomly enter characters and it will work as long as the message is long enough.

I already fixed this problem by adding

builder.setContentText(notificationMessage);

      

before setting style and bigtext. But I'm curious why I need to set the content title twice as the documentation is BigTextStyle (). BigMethod says clearly:

Specify longer text to display in large template form instead of text text.

My guess is that if the post isn't long enough, it doesn't use bigTextStyle and instead uses contentText. But why isn't this documented and clearly stated? Am I missing something? Does anyone know what's going on internally?

Thanks already!

+3
android notifications


source to share


No one has answered this question yet

Check out similar questions:

1844
How to place text horizontally and vertically in a TextView?
964
Download file from Android and show progress in ProgressDialog
823
Place the cursor at the end of the text in the EditText
388
Chrome desktop notification example
nine
Handling Multiple Notification / Stacking Notifications from GCM
2
Android release notifications
2
How to show notification content on lockscreen - Android
1
How do I stack notifications on Jelly Bean?
1
Android: create alarm reminder
0
Can I use NotificationCompat.BigTextStyle without crashing on older devices?



All Articles
Loading...
X
Show
Funny
Dev
Pics