Android embeds a new line in the notification

I need to embed a new line in the notification. I have two rows of data that are different, and I need to embed a new row to distinguish between the two. I skipped the backslash -n, but that doesn't work.

Is there any way to do this?

+6
source share
2 answers

As far as I know, there is no way to do this other than creating a custom Notification layout. The Notification documentation has a step-by-step process for doing this and is thorough enough. Here is a link to it.

Creating two lines according to your requirement will only mean adding an additional TextView to the XML format. Then you simply set each TextView text in its two lines of data, as the example shows.

+4
source

You need to create your own notification developer in your application. more details here: https://developer.android.com/guide/topics/ui/notifiers/notifications.html#CustomExpandedView , I need so long to learn how to make firebase call onMessageReceived in all cases.

  • foreground application
  • application in the background
  • The application was killed.

basically your message for firebase via api should not contain a “ notification ” in your json request for the firebase server and use only “ data ”, as shown below, the firebase service will call your onMessageReceived in all cases listed above.

 { "to": "/topics/your_topic", "data": { "key1":"data_key1", "title":"", "line1":"data1", "line2":"data2" } } 
0
source

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


All Articles