0

I have tried \n but its still but it doesn't work. Bellow is my code:

val channelId = resources.getString("NotificationChannelID")

createNotificationChannel("NotifactionChannelName", channelId)

val pendingIntent: PendingIntent =
        Intent(this, MainActivity::class.java).let { notificationIntent ->
               PendingIntent.getActivity(this, 0, notificationIntent, 0)
        }
        val notification = Notification.Builder(this, channelId)
                .setContentText("First Line \n Second Line \n")
                .setSmallIcon(R.drawable.notification_icon)
                .setContentIntent(pendingIntent)
                .build()

        startForeground(NOTIFICATION_MANAGER_NOTIFICATION_ID, notification)



       for(e in error.iterator())
       {
                Log.d("Errors: ", "$e")
       }

1 Answers1

0

You can use the "NotificationCompat.InboxStyle" Here is the snippet from the google manual.

var notification = NotificationCompat.Builder(context, CHANNEL_ID)
    .setSmallIcon(R.drawable.new_mail)
    .setContentTitle("5 New mails from " + sender.toString())
    .setContentText(subject)
    .setLargeIcon(aBitmap)
    .setStyle(NotificationCompat.InboxStyle()
            .addLine(messageSnippet1)
            .addLine(messageSnippet2))
    .build()

You can iterate over your list and use addLine to add up into the message stack.

For more just take a look into this link.

CodeRanger
  • 370
  • 3
  • 12