如何在 Android 上打破通知的行内容

Quy*_* Vu 5 php android push-notification google-cloud-messaging

我正在使用 PHP 将通知推送到 Android 和 iOS 设备。它完美的工作。但通知不能显示在多行上。

我使用了 '\n' 字符,但它只适用于 iOS,不适用于 Android。

如何在 Android 设备上显示多行通知?

Meh*_*loo 8

是的,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"));
Run Code Online (Sandbox Code Playgroud)