How to break linear notification content on Android

I use PHP to send notifications to Android and iOS devices. It worked great. But notifcaiton cannot be displayed on multi-line lines.

I used the character "\ n", but it only works on iOS, it does not work on Android.

How to show notification of multiple lines on an Android device?

+4
source share
1 answer

Yes, the notification about android does not use the \ndefault style, you must set the text in normal mode (one line), but if you want to use \nin your text, you NotificationCompat.BigTextStyle()must 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"));
+3

Source: https://habr.com/ru/post/1663033/


All Articles