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


source to share





All Articles