# CarMessage

# CarMessage

Artifact:[androidx.car.app:app](https://developer.android.com/jetpack/androidx/releases/car-app)  
[View Source](https://cs.android.com/search?q=file:androidx/car/app/messaging/model/CarMessage.java+class:androidx.car.app.messaging.model.CarMessage)  
Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/car/app/messaging/model/CarMessage "View this page in Java")

<br />

```
@CarProtocol
@RequiresCarApi(value = 7)
class CarMessage
```

<br />

*** ** * ** ***

Represents a single message in a[ConversationItem](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/ConversationItem)

## Summary

|                                                                                                                    ### Nested types                                                                                                                    |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `class `[CarMessage.Builder](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/CarMessage.Builder) A builder for[CarMessage](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/CarMessage) |

|                                    ### Public functions                                     |
|---------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)         | [equals](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/CarMessage#equals(java.lang.Object))`(other: `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?)`                                                             |
| [CarText](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText)`?` | [getBody](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/CarMessage#getBody())`()` Returns a[CarText](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText)representing the message body                                 |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?`        | [getMultimediaMimeType](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/CarMessage#getMultimediaMimeType())`()` Returns a[String](https://developer.android.com/reference/java/lang/String.html)representing the MIME type of a multimedia message |
| [Uri](https://developer.android.com/reference/android/net/Uri.html)`?`                      | [getMultimediaUri](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/CarMessage#getMultimediaUri())`()` Returns a[Uri](https://developer.android.com/reference/android/net/Uri.html)pointing to the contents of a multimedia message.                |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)               | [getReceivedTimeEpochMillis](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/CarMessage#getReceivedTimeEpochMillis())`()` Returns a`long`representing the message timestamp (in epoch millis)                                                      |
| [Person](https://developer.android.com/reference/kotlin/androidx/core/app/Person)`?`        | [getSender](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/CarMessage#getSender())`()` Returns a[Person](https://developer.android.com/reference/kotlin/androidx/core/app/Person)representing the message sender.                                 |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                 | [hashCode](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/CarMessage#hashCode())`()`                                                                                                                                                              |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)         | [isRead](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/CarMessage#isRead())`()` Returns a`boolean`, indicating whether the message has been read                                                                                                 |

## Public functions

### equals

```
fun equals(other: Any?): Boolean
```  

### getBody

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)  

```
fun getBody(): CarText?
```

Returns a[CarText](https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText)representing the message body

Messages must have one or both of the following:

- A message body (text)
- A MIME type + URI (image, audio, etc.)

|                                                                  See also                                                                   |
|---------------------------------------------------------------------------------------------------------------------------------------------|---|
| [getMultimediaMimeType](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/CarMessage#getMultimediaMimeType()) |   |
| [getMultimediaUri](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/CarMessage#getMultimediaUri())           |   |

### getMultimediaMimeType

Added in[1.4.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.4.0)  

```
fun getMultimediaMimeType(): String?
```

Returns a[String](https://developer.android.com/reference/java/lang/String.html)representing the MIME type of a multimedia message

Messages must have one or both of the following:

- A message body (text)
- A MIME type + URI (image, audio, etc.)

|                                                             See also                                                              |
|-----------------------------------------------------------------------------------------------------------------------------------|---|
| [getBody](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/CarMessage#getBody())                   |   |
| [getMultimediaUri](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/CarMessage#getMultimediaUri()) |   |

### getMultimediaUri

Added in[1.4.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.4.0)  

```
fun getMultimediaUri(): Uri?
```

Returns a[Uri](https://developer.android.com/reference/android/net/Uri.html)pointing to the contents of a multimedia message.

Messages must have one or both of the following:

- A message body (text)
- A MIME type + URI (image, audio, etc.)

|                                                                  See also                                                                   |
|---------------------------------------------------------------------------------------------------------------------------------------------|---|
| [getBody](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/CarMessage#getBody())                             |   |
| [getMultimediaMimeType](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/CarMessage#getMultimediaMimeType()) |   |

### getReceivedTimeEpochMillis

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)  

```
fun getReceivedTimeEpochMillis(): Long
```

Returns a`long`representing the message timestamp (in epoch millis)  

### getSender

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)  

```
fun getSender(): Person?
```

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

For self-sent messages, this method will return`null`or[getSelf](https://developer.android.com/reference/kotlin/androidx/car/app/messaging/model/ConversationItem#getSelf()).  

### hashCode

```
fun hashCode(): Int
```  

### isRead

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)  

```
fun isRead(): Boolean
```

Returns a`boolean`, indicating whether the message has been read