简体   繁体   中英

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 ?

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"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM