Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to break line content of notifications on Android

Iam using PHP to push notification to Android and iOS device. It perfect worked. But notifcaiton cannot be show on multi-lines.

I used '\n' character but it only working on iOS, not working on Android.

How to show notification on multi-lines on Android device ?

like image 589
Quy Nguyen Vu Avatar asked Dec 06 '16 23:12

Quy Nguyen Vu


1 Answers

Yes, the android notification don't use \n in default style, you should set a text in normal mode (single line) but if you want to use \n in your text, the NotificationCompat.BigTextStyle() should set,

NotificationCompat.Builder mBuilder =
        new NotificationCompat.Builder(thisActivity)
                .setSmallIcon(resourceDrowable)
                .setContentTitle("My notification")
                .setContentText("Hello World")
                .setAutoCancel(true)
                .setStyle(new NotificationCompat.BigTextStyle().bigText("My\nMessage"));
like image 107
Mehdi Khademloo Avatar answered Oct 21 '22 01:10

Mehdi Khademloo