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

*** ** * ** ***


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

<br />

*** ** * ** ***

Represents a single message in a `https://developer.android.com/reference/androidx/car/app/messaging/model/ConversationItem`

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/car/app/messaging/model/CarMessage.Builder` A builder for `https://developer.android.com/reference/androidx/car/app/messaging/model/CarMessage` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/car/app/messaging/model/CarMessage#equals(java.lang.Object)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html other)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarText` | `https://developer.android.com/reference/androidx/car/app/messaging/model/CarMessage#getBody()()` Returns a `https://developer.android.com/reference/androidx/car/app/model/CarText` representing the message body |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/car/app/messaging/model/CarMessage#getMultimediaMimeType()()` Returns a `https://developer.android.com/reference/java/lang/String.html` representing the MIME type of a multimedia message |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/net/Uri.html` | `https://developer.android.com/reference/androidx/car/app/messaging/model/CarMessage#getMultimediaUri()()` Returns a `https://developer.android.com/reference/android/net/Uri.html` pointing to the contents of a multimedia message. |
| `long` | `https://developer.android.com/reference/androidx/car/app/messaging/model/CarMessage#getReceivedTimeEpochMillis()()` Returns a `long` representing the message timestamp (in epoch millis) |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/app/Person` | `https://developer.android.com/reference/androidx/car/app/messaging/model/CarMessage#getSender()()` Returns a `https://developer.android.com/reference/androidx/core/app/Person` representing the message sender. |
| `int` | `https://developer.android.com/reference/androidx/car/app/messaging/model/CarMessage#hashCode()()` |
| `boolean` | `https://developer.android.com/reference/androidx/car/app/messaging/model/CarMessage#isRead()()` Returns a `boolean`, indicating whether the message has been read |

## Public methods

### equals

```
public boolean equals(@Nullable Object other)
```

### getBody

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

```
public @Nullable CarText getBody()
```

Returns a `https://developer.android.com/reference/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 |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/messaging/model/CarMessage#getMultimediaMimeType()` |   |
| `https://developer.android.com/reference/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)

```
public @Nullable String getMultimediaMimeType()
```

Returns a `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 |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/messaging/model/CarMessage#getBody()` |   |
| `https://developer.android.com/reference/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)

```
public @Nullable Uri getMultimediaUri()
```

Returns a `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 |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/messaging/model/CarMessage#getBody()` |   |
| `https://developer.android.com/reference/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)

```
public long getReceivedTimeEpochMillis()
```

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)

```
public @Nullable Person getSender()
```

Returns a `https://developer.android.com/reference/androidx/core/app/Person` representing the message sender.

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

### hashCode

```
public int hashCode()
```

### isRead

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

```
public boolean isRead()
```

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