public final class

NotificationCompat.MessagingStyle.Message

extends java.lang.Object

 java.lang.Object

↳androidx.core.app.NotificationCompat.MessagingStyle.Message

Summary

Constructors
publicMessage(java.lang.CharSequence text, long timestamp, java.lang.CharSequence sender)

Constructor

publicMessage(java.lang.CharSequence text, long timestamp, Person person)

Creates a new NotificationCompat.MessagingStyle.Message with the given text, timestamp, and sender.

Methods
public java.lang.StringgetDataMimeType()

Get the MIME type of the data pointed to by the URI.

public UrigetDataUri()

Get the the Uri pointing to the content of the message.

public BundlegetExtras()

Get the extras Bundle for this message.

public PersongetPerson()

Returns the Person sender of this message.

public java.lang.CharSequencegetSender()

Get the text used to display the contact's name in the messaging experience

public java.lang.CharSequencegetText()

Get the text to be used for this message, or the fallback text if a type and content Uri have been set

public longgetTimestamp()

Get the time at which this message arrived in ms since Unix epoch.

public NotificationCompat.MessagingStyle.MessagesetData(java.lang.String dataMimeType, Uri dataUri)

Sets a binary blob of data and an associated MIME type for a message.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Message(java.lang.CharSequence text, long timestamp, Person person)

Creates a new NotificationCompat.MessagingStyle.Message with the given text, timestamp, and sender.

Parameters:

text: A java.lang.CharSequence to be displayed as the message content
timestamp: Time at which the message arrived in ms since Unix epoch
person: A Person whose Person.getName() value is used as the display name for the sender. This should be null for messages by the current user, in which case, the platform will insert NotificationCompat.MessagingStyle.getUserDisplayName(). A Person's key should be consistent during re-posts of the notification.

public Message(java.lang.CharSequence text, long timestamp, java.lang.CharSequence sender)

Deprecated: Use the alternative constructor instead.

Constructor

Parameters:

text: A java.lang.CharSequence to be displayed as the message content
timestamp: Time at which the message arrived in ms since Unix epoch
sender: A java.lang.CharSequence to be used for displaying the name of the sender. Should be null for messages by the current user, in which case the platform will insert NotificationCompat.MessagingStyle.getUserDisplayName(). Should be unique amongst all individuals in the conversation, and should be consistent during re-posts of the notification.

Methods

public NotificationCompat.MessagingStyle.Message setData(java.lang.String dataMimeType, Uri dataUri)

Sets a binary blob of data and an associated MIME type for a message. In the case where the platform doesn't support the MIME type, the original text provided in the constructor will be used.

Parameters:

dataMimeType: The MIME type of the content. See for the list of supported MIME types on Android and Android Wear.
dataUri: The uri containing the content whose type is given by the MIME type.

  1. Notification Listeners including the System UI need permission to access the data the Uri points to. The recommended ways to do this are:
  2. Store the data in your own ContentProvider, making sure that other apps have the correct permission to access your provider. The preferred mechanism for providing access is to use per-URI permissions which are temporary and only grant access to the receiving application. An easy way to create a ContentProvider like this is to use the FileProvider helper class.
  3. Use the system MediaStore. The MediaStore is primarily aimed at video, audio and image MIME types, however beginning with Android 3.0 (API level 11) it can also store non-media types (see MediaStore.Files for more info). Files can be inserted into the MediaStore using scanFile() after which a content:// style Uri suitable for sharing is passed to the provided onScanCompleted() callback. Note that once added to the system MediaStore the content is accessible to any app on the device.

Returns:

this object for method chaining

public java.lang.CharSequence getText()

Get the text to be used for this message, or the fallback text if a type and content Uri have been set

public long getTimestamp()

Get the time at which this message arrived in ms since Unix epoch.

public Bundle getExtras()

Get the extras Bundle for this message.

public java.lang.CharSequence getSender()

Deprecated: Use NotificationCompat.MessagingStyle.Message.getPerson()

Get the text used to display the contact's name in the messaging experience

public Person getPerson()

Returns the Person sender of this message.

public java.lang.String getDataMimeType()

Get the MIME type of the data pointed to by the URI.

public Uri getDataUri()

Get the the Uri pointing to the content of the message. Can be null, in which case NotificationCompat.MessagingStyle.Message.getText() is used.