Reputation: 263
I am trying to send notification in two line when the message text is long
I have tried this :
Message message = new Message.Builder().timeToLive(30)
.delayWhileIdle(true).addData("message", msg).build();
when the text "msg" contain more char then then notification shows as message: this is a notification msg...
how to get notification in two line instead of getting ...
Upvotes: 1
Views: 724
Reputation: 9225
You cannot specify from Message how many lines the notification will use when displayed. Android displays the text passed to it as is. Even if you are able to define how many lines the notification uses, that will have to be done on the Android side not the server side.
Generally you don't have control over how many lines are used in your notification. Like @Aspicas noted you can use the ContentText for a compact version of your message and then use BigTextStyle for a larger version of your message.
Upvotes: 0
Reputation: 929
I did it like:-
Message message = new Message.Builder()
.timeToLive(30)
.delayWhileIdle(true)
.addData("title", msgTitle)
.addData("text", msgText)
.build();
And in the client app side, you can extract the title and text seperately and display it in two lines.
Upvotes: 0
Reputation: 4497
Try this:
NotificationManager notificationManager = getNotificationManager();
PendingIntent pi = getPendingIntent();
Builder builder = new Notification.Builder(this);
builder.setContentTitle(title)
.setContentText(message)
.setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(true);
Notification notification = new Notification.BigTextStyle(builder).bigText(message).build();
NOTE
It's reports "an error": Call requires API level 16
but i'm using on Lower APIS...
Upvotes: 1