简体   繁体   English

如何在Android上中断通知的行内容

[英]How to break line content of notifications on Android

Iam using PHP to push notification to Android and iOS device. Iam使用PHP将通知推送到Android和iOS设备。 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. 我使用了'\\ n'字符,但是它只能在iOS上使用,而不能在Android上使用。

How to show notification on multi-lines on Android device ? 如何在Android设备上的多行显示通知?

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, 是的,Android通知不使用默认样式的\\n ,您应该以普通模式(单行)设置文本,但是如果要在文本中使用\\n ,则应该设置NotificationCompat.BigTextStyle()

NotificationCompat.Builder mBuilder =
        new NotificationCompat.Builder(thisActivity)
                .setSmallIcon(resourceDrowable)
                .setContentTitle("My notification")
                .setContentText("Hello World")
                .setAutoCancel(true)
                .setStyle(new NotificationCompat.BigTextStyle().bigText("My\nMessage"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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