2

My status bar notification message is too long, so I want to display it on multiple lines but i don't know why its not displaying that way.

Here is my code:

String msg = "text1 text2 text3 text4 text5";

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);

mBuilder.setContentTitle(context.getResources().getString(R.string.time_to_brush_title));
mBuilder.setContentText(msg);
mBuilder.setTicker(context.getResources().getString(R.string.time_to_brush_title));
mBuilder.setSmallIcon(R.drawable.ic_launcher);
mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(msg));

However, This is what the notification bar contains:

text1 text2 text3 ...
Sky Kelsey
  • 19,192
  • 5
  • 36
  • 77
abh22ishek
  • 2,631
  • 4
  • 27
  • 47

1 Answers1

1

If you want to use this kind of notification in 4.1> then use

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
    .setSmallIcon(R.drawable.notification_icon)
    .setContentTitle("Event tracker")
    .setContentText("Events received")
NotificationCompat.InboxStyle inboxStyle =
        new NotificationCompat.InboxStyle();
String[] events = new String[6];
// Sets a title for the Inbox in expanded layout
inboxStyle.setBigContentTitle("Event tracker details:");
...
// Moves events into the expanded layout
for (int i=0; i < events.length; i++) {

    inboxStyle.addLine(events[i]);
}
// Moves the expanded layout object into the notification object.
mBuilder.setStyle(inBoxStyle);

here's the reference link https://developer.android.com/guide/topics/ui/notifiers/notifications.html

NullByte
  • 165
  • 1
  • 6