added in version 24.1.0
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1

NotificationCompat.MessagingStyle

public static class NotificationCompat.MessagingStyle
extends NotificationCompat.Style

java.lang.Object
   ↳ android.support.v4.app.NotificationCompat.Style
     ↳ android.support.v4.app.NotificationCompat.MessagingStyle


Helper class for generating large-format notifications that include multiple back-and-forth messages of varying types between any number of people.
In order to get a backwards compatible behavior, the app needs to use the v7 version of the notification builder together with this style, otherwise the user will see the normal notification view.
Use setConversationTitle(CharSequence) to set a conversation title for group chats with more than two people. This could be the user-created name of the group or, if it doesn't have a specific name, a list of the participants in the conversation. Do not set a conversation title for one-on-one chats, since platforms use the existence of this field as a hint that the conversation is a group.
This class is a "rebuilder": It attaches to a Builder object and modifies its behavior, like so:


 Notification notification = new Notification.Builder()
     .setContentTitle("2 new messages with " + sender.toString())
     .setContentText(subject)
     .setSmallIcon(R.drawable.new_message)
     .setLargeIcon(aBitmap)
     .setStyle(new Notification.MessagingStyle(resources.getString(R.string.reply_name))
         .addMessage(messages[0].getText(), messages[0].getTime(), messages[0].getSender())
         .addMessage(messages[1].getText(), messages[1].getTime(), messages[1].getSender()))
     .build();
 

Summary

Nested classes

class NotificationCompat.MessagingStyle.Message

 

Constants

int MAXIMUM_RETAINED_MESSAGES

The maximum number of messages that will be retained in the Notification itself (the number displayed is up to the platform).

Public constructors

NotificationCompat.MessagingStyle(CharSequence userDisplayName)

Public methods

void addCompatExtras(Bundle extras)
NotificationCompat.MessagingStyle addMessage(CharSequence text, long timestamp, CharSequence sender)

Adds a message for display by this notification.

NotificationCompat.MessagingStyle addMessage(NotificationCompat.MessagingStyle.Message message)

Adds a NotificationCompat.MessagingStyle.Message for display in this notification.

static NotificationCompat.MessagingStyle extractMessagingStyleFromNotification(Notification notification)

Retrieves a NotificationCompat.MessagingStyle from a Notification, enabling an application that has set a NotificationCompat.MessagingStyle using NotificationCompat or Notification.Builder to send messaging information to another application using NotificationCompat, regardless of the API level of the system.

CharSequence getConversationTitle()

Return the title to be displayed on this conversation.

List<NotificationCompat.MessagingStyle.Message> getMessages()

Gets the list of Message objects that represent the notification

CharSequence getUserDisplayName()

Returns the name to be displayed for any replies sent by the user

boolean isGroupConversation()

Returns true if this notification represents a group conversation, otherwise false.

NotificationCompat.MessagingStyle setConversationTitle(CharSequence conversationTitle)

Sets the title to be displayed on this conversation.

NotificationCompat.MessagingStyle setGroupConversation(boolean isGroupConversation)

Sets whether this conversation notification represents a group.

Inherited methods

From class android.support.v4.app.NotificationCompat.Style