# CarAppExtender.Builder

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/notification/CarAppExtender.java+class:androidx.car.app.notification.CarAppExtender.Builder) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

*** ** * ** ***


```
public final class CarAppExtender.Builder
```

<br />

*** ** * ** ***

A builder of `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder#Builder()()` Creates an empty `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder` instance. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder` | `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder#addAction(android.app.Notification.Action)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Notification.Action.html action)` Adds an `https://developer.android.com/reference/android/app/Notification.Action.html` to this notification. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder` | `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder#addAction(int,java.lang.CharSequence,android.app.PendingIntent)( @https://developer.android.com/reference/androidx/annotation/DrawableRes int icon, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html title, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/PendingIntent.html intent )` Adds an action to this notification. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender` | `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder#build()()` Constructs the `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender` defined by this builder. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder` | `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder#setChannelId(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html channelId)` For Android Automotive OS only, sets the channel id of the notification channel to be used in the car. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder` | `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder#setColor(androidx.car.app.model.CarColor)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarColor color)` Sets the background color of the notification in the car screen. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder` | `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder#setContentIntent(android.app.PendingIntent)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/PendingIntent.html contentIntent)` Supplies a `https://developer.android.com/reference/android/app/PendingIntent.html` to send when the notification is clicked in the car. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder` | `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder#setContentText(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html contentText)` Sets the content text of the notification in the car screen. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder` | `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder#setContentTitle(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html contentTitle)` Sets the title of the notification in the car screen. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder` | `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder#setDeleteIntent(android.app.PendingIntent)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/PendingIntent.html deleteIntent)` Supplies a `https://developer.android.com/reference/android/app/PendingIntent.html` to send when the user clears the notification by either using the "clear all" functionality in the notification center, or tapping the individual "close" buttons on the notification in the car screen. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder` | `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder#setImportance(int)(int importance)` For Android Auto only, sets the importance of the notification in the car screen. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder` | `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder#setLargeIcon(android.graphics.Bitmap)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Bitmap.html bitmap)` Sets the large icon of the notification in the car screen. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder` | `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder#setSmallIcon(int)(int iconResId)` Sets the small icon of the notification in the car screen. |

## Public constructors

### Builder

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

```
public Builder()
```

Creates an empty `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder` instance.

## Public methods

### addAction

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

```
public @NonNull CarAppExtender.Builder addAction(@NonNull Notification.Action action)
```

Adds an `https://developer.android.com/reference/android/app/Notification.Action.html` to this notification.

Actions are typically displayed by the system as a button adjacent to the notification content.

A notification may offer up to 2 actions. The system may not display some actions in the compact notification UI (e.g. heads-up-notifications).

If actions are added to a CarAppExtender, any actions directly added the notification being extended, for example via `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#addAction(androidx.core.app.NotificationCompat.Action)`, are ignored when the notification is shown in a car. Effectively, these actions override the notification's actions in the car environment. For example:

```
notificationBuilder.addAction(action1)
carExtenderBuilder.addAction(action2)
notificationBuilder.extend(carExtenderBuilder.build())
```

The mobile device will only show action1 and the car will only show action2.

### addAction

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

```
public @NonNull CarAppExtender.Builder addAction(
    @DrawableRes int icon,
    @NonNull CharSequence title,
    @NonNull PendingIntent intent
)
```

Adds an action to this notification.

Actions are typically displayed by the system as a button adjacent to the notification content.

A notification may offer up to 2 actions. The system may not display some actions in the compact notification UI (e.g. heads-up-notifications).

If actions are added to a CarAppExtender, any actions directly added the notification being extended, for example via `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#addAction(int,java.lang.CharSequence,android.app.PendingIntent)`, are ignored when the notification is shown in a car. Effectively, these actions override the notification's actions in the car environment. For example:

```
notificationBuilder.addAction(action1)
carExtenderBuilder.addAction(action2)
notificationBuilder.extend(carExtenderBuilder.build())
```

The mobile device will only show action1 and the car will only show action2.

This method is equivalent to `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#addAction(int,java.lang.CharSequence,android.app.PendingIntent)` for the car screen.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/DrawableRes int icon` | resource ID of a drawable that represents the action. In order to display the actions properly, a valid resource id for the icon must be provided |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html title` | text describing the action |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/PendingIntent.html intent` | `https://developer.android.com/reference/android/app/PendingIntent.html` to send when the action is invoked. In the case of navigation notifications in the rail widget, this intent will be sent when the user taps on the action icon in the rail widget |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `title` or `intent` are `null` |

### build

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

```
public @NonNull CarAppExtender build()
```

Constructs the `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender` defined by this builder.

### setChannelId

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

```
public @NonNull CarAppExtender.Builder setChannelId(@NonNull String channelId)
```

For Android Automotive OS only, sets the channel id of the notification channel to be used in the car.

This is used in the case where your notification is to have a different importance in the car then it does on the phone.

It is used for the same purposes you'd use `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder#setImportance(int)` for Auto.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder#setImportance(int)` |   |

### setColor

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

```
public @NonNull CarAppExtender.Builder setColor(@NonNull CarColor color)
```

Sets the background color of the notification in the car screen.

This method is equivalent to `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setColor(int)` for the car screen.

This color is only used for navigation notifications. See the "Navigation" section of `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender` for more details.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `color` is `null` |

### setContentIntent

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

```
public @NonNull CarAppExtender.Builder setContentIntent(@NonNull PendingIntent contentIntent)
```

Supplies a `https://developer.android.com/reference/android/app/PendingIntent.html` to send when the notification is clicked in the car.

If not set, the notification's content intent will be used.

In the case of navigation notifications in the rail widget, this intent will be sent when the user taps on the rail widget.

This method is equivalent to `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setContentIntent(android.app.PendingIntent)` for the car screen.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/PendingIntent.html contentIntent` | override for the notification's content intent. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `contentIntent` is `null` |

### setContentText

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

```
public @NonNull CarAppExtender.Builder setContentText(@NonNull CharSequence contentText)
```

Sets the content text of the notification in the car screen.

This method is equivalent to `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setContentText(java.lang.CharSequence)` for the car screen.

Spans are not supported in the input string and will be ignored.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html contentText` | override for the notification's content text. If set to an empty string, it will be treated as if there is no context text |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `contentText` is `null` |

### setContentTitle

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

```
public @NonNull CarAppExtender.Builder setContentTitle(@NonNull CharSequence contentTitle)
```

Sets the title of the notification in the car screen.

This will be the most prominently displayed text in the car notification.

This method is equivalent to `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setContentTitle(java.lang.CharSequence)` for the car screen.

Spans are not supported in the input string and will be ignored.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `contentTitle` is `null` |

### setDeleteIntent

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

```
public @NonNull CarAppExtender.Builder setDeleteIntent(@NonNull PendingIntent deleteIntent)
```

Supplies a `https://developer.android.com/reference/android/app/PendingIntent.html` to send when the user clears the notification by either using the "clear all" functionality in the notification center, or tapping the individual "close" buttons on the notification in the car screen.

If not set, the notification's content intent will be used.

This method is equivalent to `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setDeleteIntent(android.app.PendingIntent)` for the car screen.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/PendingIntent.html deleteIntent` | override for the notification's delete intent |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `deleteIntent` is `null` |

### setImportance

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

```
public @NonNull CarAppExtender.Builder setImportance(int importance)
```

For Android Auto only, sets the importance of the notification in the car screen.

The default value is `https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat#IMPORTANCE_UNSPECIFIED()`, and will not be used to override.

The importance is used to determine whether the notification will show as a HUN on the car screen. See the class description for more details.

See `https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat` for all supported importance values.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender.Builder#setChannelId(java.lang.String)` |   |

### setLargeIcon

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

```
public @NonNull CarAppExtender.Builder setLargeIcon(@NonNull Bitmap bitmap)
```

Sets the large icon of the notification in the car screen.

This is used as the secondary icon to represent the notification in the notification center.

This method is equivalent to `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setLargeIcon(android.graphics.Bitmap)` for the car screen.

The large icon will be shown in the notification badge. If the large icon is not set in the `https://developer.android.com/reference/androidx/car/app/notification/CarAppExtender` or the notification, the small icon will show instead.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `bitmap` is `null` |

### setSmallIcon

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

```
public @NonNull CarAppExtender.Builder setSmallIcon(int iconResId)
```

Sets the small icon of the notification in the car screen.

This is used as the primary icon to represent the notification.

This method is equivalent to `https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setSmallIcon(int)` for the car screen.