Android : Unable to display multiple lines of text in Notification

十年热恋 提交于 2019-12-05 08:29:08

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.

Just set notification style to BigText

   NotificationCompat.BigTextStyle bigStyle =
   new NotificationCompat.BigTextStyle();
   bigStyle.setBigContentTitle(title);
   bigStyle.bigText(messageBody);
   builder.setStyle(bigStyle);

Try to set content intent value as well.

Notification.Builder builder = new Notification.Builder(this);
builder.setContentTitle("Big text Notification")
        .setContentText("Big text Notification")
        .setSmallIcon(R.drawable.ic_launcher)
        .setAutoCancel(true)

        .setContentIntent(pi) // <- this new line

        .setPriority(Notification.PRIORITY_HIGH)
        .addAction(R.drawable.ic_launcher, "show activity", pi);
Sportivivi

.setPriority(Notification.PRIORITY_HIGH) - this line solved my problem. The multiline conserve size.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!