Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message#pubctors) \| [Methods](https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message#inhmethods)

# Notification.MessagingStyle.Message

*** ** * ** ***

` public static final class Notification.MessagingStyle.Message `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.Notification.MessagingStyle.Message |

<br />

*** ** * ** ***

An object representing a simple message or piece of media within a mixed-media message.

This object can only represent text or a single binary piece of media. For apps which support mixed-media messages (e.g. text + image), multiple Messages should be used, one to represent each piece of the message, and they should all be given the same timestamp. For consistency, a text message should be added last of all Messages with the same timestamp.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message#Message(java.lang.CharSequence,%20long,%20android.app.Person)(https://developer.android.com/reference/java/lang/CharSequence text, long timestamp, https://developer.android.com/reference/android/app/Person sender) ` Constructor |
| ` https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message#Message(java.lang.CharSequence,%20long,%20java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence text, long timestamp, https://developer.android.com/reference/java/lang/CharSequence sender) ` *This constructor is deprecated. use `Message(CharSequence, long, Person)`* |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message#getDataMimeType()() ` Get the MIME type of the data pointed to by the Uri |
| ` https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message#getDataUri()() ` Get the Uri pointing to the content of the message. |
| ` https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message#getExtras()() ` Get the extras Bundle for this message. |
| ` static https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message>` | ` https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message#getMessagesFromBundleArray(android.os.Parcelable[])(https://developer.android.com/reference/android/os/Parcelable bundles) ` Returns a list of messages read from the given bundle list, e.g. |
| ` https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message#getSender()() ` *This method was deprecated in API level 28. use `https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message#getSenderPerson()`* |
| ` https://developer.android.com/reference/android/app/Person` | ` https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message#getSenderPerson()() ` Get the sender associated with this message. |
| ` https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message#getText()() ` Get the text to be used for this message, or the fallback text if a type and content Uri have been set |
| ` long` | ` https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message#getTimestamp()() ` Get the time at which this message arrived |
| ` https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message` | ` https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message#setData(java.lang.String,%20android.net.Uri)(https://developer.android.com/reference/java/lang/String dataMimeType, https://developer.android.com/reference/android/net/Uri dataUri) ` Sets a binary blob of data and an associated MIME type for a message. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### Message

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Message (CharSequence text, 
                long timestamp, 
                Person sender)
```

Constructor

<br />

| Parameters ||
|---|---|
| `text` | `CharSequence`: a `https://developer.android.com/reference/java/lang/CharSequence` to be displayed as the message content. This value cannot be `null`. <br /> |
| `timestamp` | `long`: time at which the message arrived <br /> |
| `sender` | `Person`: the `https://developer.android.com/reference/android/app/Person` who sent the message. Should be `null` for messages by the current user, in which case the platform will insert the user set in `MessagingStyle(Person)`. The person provided should contain an Icon, set with `https://developer.android.com/reference/android/app/Person.Builder#setIcon(android.graphics.drawable.Icon)` and also have a name provided with `https://developer.android.com/reference/android/app/Person.Builder#setName(java.lang.CharSequence)`. If multiple users have the same name, consider providing a key with `https://developer.android.com/reference/android/app/Person.Builder#setKey(java.lang.String)` in order to differentiate between the different users. <br /> |

### Message

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Message (CharSequence text, 
                long timestamp, 
                CharSequence sender)
```

<br />

**This constructor is deprecated.**   

use `Message(CharSequence, long, Person)`

Constructor

<br />

| Parameters ||
|---|---|
| `text` | `CharSequence`: A `https://developer.android.com/reference/java/lang/CharSequence` to be displayed as the message content <br /> |
| `timestamp` | `long`: Time at which the message arrived <br /> |
| `sender` | `CharSequence`: A `https://developer.android.com/reference/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 `https://developer.android.com/reference/android/app/Notification.MessagingStyle#getUserDisplayName()`. Should be unique amongst all individuals in the conversation, and should be consistent during re-posts of the notification. <br /> |

## Public methods

### getDataMimeType

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getDataMimeType ()
```

Get the MIME type of the data pointed to by the Uri

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### getDataUri

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Uri getDataUri ()
```

Get the Uri pointing to the content of the message. Can be `null`, in which case `https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message#getText()` is used.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | <br /> |

### getExtras

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Bundle getExtras ()
```

Get the extras Bundle for this message.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | <br /> |

### getMessagesFromBundleArray

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static List<Notification.MessagingStyle.Message> getMessagesFromBundleArray (Parcelable[] bundles)
```

Returns a list of messages read from the given bundle list, e.g. `https://developer.android.com/reference/android/app/Notification#EXTRA_MESSAGES` or `https://developer.android.com/reference/android/app/Notification#EXTRA_HISTORIC_MESSAGES`.

<br />

| Parameters ||
|---|---|
| `bundles` | `Parcelable`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message>` | This value cannot be `null`. <br /> |

### getSender

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public CharSequence getSender ()
```

<br />

**This method was deprecated in API level 28.**   

use `https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message#getSenderPerson()`

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence` | <br /> |

### getSenderPerson

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Person getSenderPerson ()
```

Get the sender associated with this message.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Person` | This value may be `null`. <br /> |

### getText

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public CharSequence getText ()
```

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence` | <br /> |

### getTimestamp

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long getTimestamp ()
```

Get the time at which this message arrived

<br />

| Returns ||
|---|---|
| `long` | <br /> |

### setData

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Notification.MessagingStyle.Message setData (String dataMimeType, 
                Uri dataUri)
```

Sets a binary blob of data and an associated MIME type for a message. In the case where the platform or the UI state doesn't support the MIME type, the original text provided in the constructor will be used. When this data can be presented to the user, the original text will only be used as accessibility text.

<br />

| Parameters ||
|---|---|
| `dataMimeType` | `String`: The MIME type of the content. See `https://developer.android.com/reference/android/graphics/ImageDecoder#isMimeTypeSupported(java.lang.String)` for a list of supported image MIME types. <br /> |
| `dataUri` | `Uri`: The uri containing the content whose type is given by the MIME type. Notification Listeners including the System UI need permission to access the data the Uri points to. The recommended ways to do this are: 1. 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. 2. 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. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/Notification.MessagingStyle.Message` | this object for method chaining <br /> |