NotificationCompat.MessagingStyle

public class NotificationCompat.MessagingStyle extends NotificationCompat.Style


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 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

Constants

static final int

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

Public constructors

This method is deprecated.

Use #MessagingStyle(Person) instead.

Creates a new MessagingStyle object.

Public methods

@NonNull NotificationCompat.MessagingStyle

Adds a Message for historic context in this notification.

@NonNull NotificationCompat.MessagingStyle
addMessage(
    @Nullable CharSequence text,
    long timestamp,
    @Nullable CharSequence sender
)

This method is deprecated.

Use addMessage or addMessage

@