# NotificationCompat.CarExtender

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.CarExtender) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***


```
class NotificationCompat.CarExtender : NotificationCompat.Extender
```

<br />

*** ** * ** ***

Helper class to add Android Auto extensions to notifications. To create a notification with car extensions:

1. Create an `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder`, setting any desired properties.
2. Create a `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender`.
3. Set car-specific properties using the `add` and `set` methods of `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender`.
4. Call `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder#extend(androidx.core.app.NotificationCompat.Extender)` to apply the extensions to a notification.
5. Post the notification to the notification system with the `NotificationManagerCompat.notify(...)` methods and not the `NotificationManager.notify(...)` methods.

```kotlin
Notification notification = new NotificationCompat.Builder(context)
        ...
        .extend(new CarExtender()
                .set*(...))
        .build();
```

Car extensions can be accessed on an existing notification by using the `CarExtender(Notification)` constructor, and then using the `get` methods to access values.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender.UnreadConversation` **This class is deprecated.** `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender.UnreadConversation` is no longer supported. <br /> |
| `class https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender.UnreadConversation.Builder` **This class is deprecated.** Deprecated in Java |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender#CarExtender()()` Create a `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender` with default options. |
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender#CarExtender(android.app.Notification)(notification: https://developer.android.com/reference/android/app/Notification.html)` Create a `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender` from the CarExtender options of an existing Notification. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder` | `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender#extend(androidx.core.app.NotificationCompat.Builder)(builder: https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder)` Apply car extensions to a notification that is being built. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender#getColor()()` Gets the accent color. |
| `https://developer.android.com/reference/android/graphics/Bitmap.html?` | `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender#getLargeIcon()()` Gets the large icon used in this car notification, or null if no icon has been set. |
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender.UnreadConversation?` | `[getUnreadConversation](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender#getUnreadConversation())()` **This function is deprecated.** `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender.UnreadConversation` is no longer supported. <br /> |
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender` | `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender#setColor(int)(color: @https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the accent color to use when Android Auto presents the notification. |
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender` | `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender#setLargeIcon(android.graphics.Bitmap)(largeIcon: https://developer.android.com/reference/android/graphics/Bitmap.html?)` Sets the large icon of the car notification. |
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender` | `[setUnreadConversation](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender#setUnreadConversation(androidx.core.app.NotificationCompat.CarExtender.UnreadConversation))( unreadConversation: https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender.UnreadConversation? )` **This function is deprecated.** `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender.UnreadConversation` is no longer supported. <br /> |

## Public constructors

### CarExtender

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

```
CarExtender()
```

Create a `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender` with default options.

### CarExtender

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

```
CarExtender(notification: Notification)
```

Create a `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender` from the CarExtender options of an existing Notification.

| Parameters |
|---|---|
| `notification: https://developer.android.com/reference/android/app/Notification.html` | The notification from which to copy options. |

## Public functions

### extend

```
fun extend(builder: NotificationCompat.Builder): NotificationCompat.Builder
```

Apply car extensions to a notification that is being built. This is typically called by the `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder#extend(androidx.core.app.NotificationCompat.Extender)` method of `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder`.

### getColor

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

```
fun getColor(): @ColorInt Int
```

Gets the accent color.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender#setColor(int)` |   |

### getLargeIcon

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

```
fun getLargeIcon(): Bitmap?
```

Gets the large icon used in this car notification, or null if no icon has been set.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap.html?` | The large icon for the car notification. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender#setLargeIcon(android.graphics.Bitmap)` |   |

### getUnreadConversation

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

```
fun [getUnreadConversation](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender#getUnreadConversation())(): NotificationCompat.CarExtender.UnreadConversation?
```

> [!CAUTION]
> **This function is deprecated.**   
>
> `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender.UnreadConversation` is no longer supported. Use `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle` instead.

Returns the unread conversation conveyed by this notification.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender#setUnreadConversation(androidx.core.app.NotificationCompat.CarExtender.UnreadConversation)` |   |

### setColor

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

```
fun setColor(color: @ColorInt Int): NotificationCompat.CarExtender
```

Sets the accent color to use when Android Auto presents the notification. Android Auto uses the color set with `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder#setColor(int)` to accent the displayed notification. However, not all colors are acceptable in an automotive setting. This method can be used to override the color provided in the notification in such a situation.

### setLargeIcon

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

```
fun setLargeIcon(largeIcon: Bitmap?): NotificationCompat.CarExtender
```

Sets the large icon of the car notification. If no large icon is set in the extender, Android Auto will display the icon specified by `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.Builder#setLargeIcon(android.graphics.Bitmap)`

| Parameters |
|---|---|
| `largeIcon: https://developer.android.com/reference/android/graphics/Bitmap.html?` | The large icon to use in the car notification. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender` | This object for method chaining. |

### setUnreadConversation

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

```
fun [setUnreadConversation](https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender#setUnreadConversation(androidx.core.app.NotificationCompat.CarExtender.UnreadConversation))(
    unreadConversation: NotificationCompat.CarExtender.UnreadConversation?
): NotificationCompat.CarExtender
```

> [!CAUTION]
> **This function is deprecated.**   
>
> `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender.UnreadConversation` is no longer supported. Use `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.MessagingStyle` instead.

Sets the unread conversation in a message notification.

| Parameters |
|---|---|
| `unreadConversation: https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender.UnreadConversation?` | The unread part of the conversation this notification conveys. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.CarExtender` | This object for method chaining. |