I am trying to display multiple lines of Text using BigTextStyle
in Notification but unable to do so. I am using the code below.
public void sendNotification(View view) {
String msgText = "Jeally Bean Notification example!! "
+ "where you will see three different kind of notification. "
+ "you can even put the very long string here.";
NotificationManager notificationManager = getNotificationManager();
PendingIntent pi = getPendingIntent();
android.app.Notification.Builder builder = new Notification.Builder(
this);
builder.setContentTitle("Big text Notofication")
.setContentText("Big text Notification")
.setSmallIcon(R.drawable.ic_launcher).setAutoCancel(true)
.setPriority(Notification.PRIORITY_HIGH)
.addAction(R.drawable.ic_launcher, "show activity", pi);
Notification notification = new Notification.BigTextStyle(builder)
.bigText(msgText).build();
notificationManager.notify(0, notification);
}
public NotificationManager getNotificationManager() {
return (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
}
public PendingIntent getPendingIntent() {
return PendingIntent.getActivity(this, 0, new Intent(this,
MainActivity.class), 0);
}
I can't even see 'msgText' in the notification. Any idea why? Thanks for helping.
Solved!
Code was fine, its just that there was not enough space for big notification. When I disconnected data cable, it got displayed in desired manner. :-)
Thanks to all who tried to help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With