Reputation: 107
I doing one notification with multiple line, code like:
private void sendNotification(String msg) {
mNotificationManager = (NotificationManager)
this.getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, Home.class), 0);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher).setContentTitle("");
//
// Set Big View style to see full content of the message
NotificationCompat.BigTextStyle inboxStyle =
new NotificationCompat.BigTextStyle();
inboxStyle.setBuilder(mBuilder);
inboxStyle.bigText(msg);
inboxStyle.setBigContentTitle("");
inboxStyle.setSummaryText("");
// Moves the big view style object into the notification object.
mBuilder.setStyle(inboxStyle);
mBuilder.setContentText(msg);
mBuilder.setDefaults(Notification.DEFAULT_ALL);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}
But it's only show one line notification, I would like it show all content of notification with multiple line. Can you help me?
Thanks you so much
Upvotes: 1
Views: 9083
Reputation: 4175
try to add both SetStyle
and SetPriorityas
as the following :
.SetStyle(new Notification.BigTextStyle().BigText(message.Long_Message))
.SetPriority((int)NotificationPriority.Max)
it is working fine for me :)
Upvotes: 0
Reputation: 11188
There are three styles to be used with the big view: big picture style, big text style, Inbox style. The following code demonstrates the usage of the BigTextStyle() which allows to use up to 256 dp.
String longText = "...";
Notification noti = new Notification.Builder(this).
.....
.setStyle(new Notification.BigTextStyle().bigText(longText))
for more reference ,check this reference link
Upvotes: 4
Reputation: 11197
Yes it can be done. Just use the Big View for notification. See the official documentation.
Here is a good tutorial by vogella.
Upvotes: 1
Reputation: 722
What you are looking for is Big view in Notifications:
https://developer.android.com/guide/topics/ui/notifiers/notifications.html#BigNotify
Upvotes: 0