# NotificationCompat.MessagingStyle.Message

# NotificationCompat.MessagingStyle.Message

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/app/NotificationCompat.java+class:androidx.core.app.NotificationCompat.MessagingStyle.Message)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/app/NotificationCompat.MessagingStyle.Message "View this page in Java")

<br />

```
class NotificationCompat.MessagingStyle.Message
```

<br />

*** ** * ** ***

## Summary

|                                                                                                                                                                                                                                                                                                                        ### Public constructors                                                                                                                                                                                                                                                                                                                         |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message#Message(java.lang.CharSequence,long,androidx.core.app.Person))`(text: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`?, timestamp: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`, person: `[Person](https://developer.android.com/reference/kotlin/androidx/core/app/Person)`?)` Creates a new[Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message)with the given text, timestamp, and sender. |
| ~~[Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message#Message(java.lang.CharSequence,long,java.lang.CharSequence))~~`(text: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`?, timestamp: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`, sender: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`?)` **This function is deprecated.** Use the alternative constructor instead. <br />                                                                               |

|                                                                  ### Public functions                                                                   |
|---------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?`                                                                    | [getDataMimeType](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message#getDataMimeType())`()` Get the MIME type of the data pointed to by the URI.                                                                                                                                                                                                                     |
| [Uri](https://developer.android.com/reference/android/net/Uri.html)`?`                                                                                  | [getDataUri](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message#getDataUri())`()` Get the the Uri pointing to the content of the message.                                                                                                                                                                                                                            |
| [Bundle](https://developer.android.com/reference/android/os/Bundle.html)                                                                                | [getExtras](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message#getExtras())`()` Get the extras Bundle for this message.                                                                                                                                                                                                                                              |
| [Person](https://developer.android.com/reference/kotlin/androidx/core/app/Person)`?`                                                                    | [getPerson](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message#getPerson())`()` Returns the[Person](https://developer.android.com/reference/kotlin/androidx/core/app/Person)sender of this message.                                                                                                                                                                  |
| [CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`?`                                                       | ~~[getSender](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message#getSender())~~`()` **This function is deprecated.** Use[getPerson](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message#getPerson()) <br />                                                                                                   |
| [CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`?`                                                       | [getText](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.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://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                                                           | [getTimestamp](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message#getTimestamp())`()` Get the time at which this message arrived in ms since Unix epoch.                                                                                                                                                                                                             |
| [NotificationCompat.MessagingStyle.Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message) | [setData](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message#setData(java.lang.String,android.net.Uri))`(dataMimeType: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?, dataUri: `[Uri](https://developer.android.com/reference/android/net/Uri.html)`?)` Sets a binary blob of data and an associated MIME type for a message. |

## Public constructors

### Message

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
Message(text: CharSequence?, timestamp: Long, person: Person?)
```

Creates a new[Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message)with the given text, timestamp, and sender.  

|                                                Parameters                                                 |
|-----------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `text: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`?` | A[CharSequence](https://developer.android.com/reference/java/lang/CharSequence.html)to be displayed as the message content                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `timestamp: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                | Time at which the message arrived in ms since Unix epoch                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `person: `[Person](https://developer.android.com/reference/kotlin/androidx/core/app/Person)`?`            | A[Person](https://developer.android.com/reference/kotlin/androidx/core/app/Person)whose[getName](https://developer.android.com/reference/kotlin/androidx/core/app/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[getUserDisplayName](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#getUserDisplayName()). A[Person](https://developer.android.com/reference/kotlin/androidx/core/app/Person)'s key should be consistent during re-posts of the notification. |

### Message

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
[Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message#Message(java.lang.CharSequence,long,java.lang.CharSequence))(text: CharSequence?, timestamp: Long, sender: CharSequence?)
```
| **This function is deprecated.**   
|
| Use the alternative constructor instead.

Constructor  

|                                                 Parameters                                                  |
|-------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `text: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`?`   | A[CharSequence](https://developer.android.com/reference/java/lang/CharSequence.html)to be displayed as the message content                                                                                                                                                                                                                                                                                                                                                                              |
| `timestamp: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                  | Time at which the message arrived in ms since Unix epoch                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `sender: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`?` | A[CharSequence](https://developer.android.com/reference/java/lang/CharSequence.html)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[getUserDisplayName](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle#getUserDisplayName()). Should be unique amongst all individuals in the conversation, and should be consistent during re-posts of the notification. |

## Public functions

### getDataMimeType

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun getDataMimeType(): String?
```

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

### getDataUri

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun getDataUri(): Uri?
```

Get the the Uri pointing to the content of the message. Can be null, in which case {@see #getText()} is used.  

### getExtras

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun getExtras(): Bundle
```

Get the extras Bundle for this message.  

### getPerson

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun getPerson(): Person?
```

Returns the[Person](https://developer.android.com/reference/kotlin/androidx/core/app/Person)sender of this message.  

### getSender

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun [getSender](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message#getSender())(): CharSequence?
```
| **This function is deprecated.**   
|
| Use[getPerson](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message#getPerson())

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

### getText

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun getText(): CharSequence?
```

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

### getTimestamp

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun getTimestamp(): Long
```

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

### setData

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun setData(dataMimeType: String?, dataUri: Uri?): NotificationCompat.MessagingStyle.Message
```

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: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?` | The MIME type of the content. See[isMimeTypeSupported](https://developer.android.com/reference/android/graphics/ImageDecoder.html#isMimeTypeSupported(java.lang.String))for a list of supported image MIME types.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `dataUri: `[Uri](https://developer.android.com/reference/android/net/Uri.html)`?`                    | 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. |

|                                                                         Returns                                                                         |
|---------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------|
| [NotificationCompat.MessagingStyle.Message](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle.Message) | this object for method chaining |