CarAppExtender.Builder


class CarAppExtender.Builder


A builder of CarAppExtender.

Summary

Public constructors

Creates an empty Builder instance.

Public functions

CarAppExtender.Builder
addAction(icon: @DrawableRes Int, title: CharSequence, intent: PendingIntent)

Adds an action to this notification.

CarAppExtender

Constructs the CarAppExtender defined by this builder.

CarAppExtender.Builder
setChannelId(channelId: String)

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

CarAppExtender.Builder

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

CarAppExtender.Builder

Supplies a PendingIntent to send when the notification is clicked in the car.

CarAppExtender.Builder

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

CarAppExtender.Builder

Sets the title of the notification in the car screen.

CarAppExtender.Builder

Supplies a PendingIntent 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.

CarAppExtender.Builder
setImportance(importance: Int)

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

CarAppExtender.Builder

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

CarAppExtender.Builder
setSmallIcon(iconResId: Int)

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

Public constructors

Builder

Added in 1.0.0
Builder()

Creates an empty Builder instance.

Public functions

addAction

Added in 1.0.0
fun addAction(icon: @DrawableRes Int, title: CharSequence, intent: PendingIntent): CarAppExtender.Builder

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 one or more action is added with this method, any action added by addAction will be ignored.

This method is equivalent to addAction for the car screen.

Parameters
icon: @DrawableRes Int

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

title: CharSequence

text describing the action

intent: PendingIntent

PendingIntent 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
java.lang.NullPointerException

if title or intent are null

build

Added in 1.0.0
fun build(): CarAppExtender

Constructs the CarAppExtender defined by this builder.

setChannelId

Added in 1.1.0
fun setChannelId(channelId: String): CarAppExtender.Builder

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 setImportance for Auto.

See also
setImportance

setColor

Added in 1.0.0
fun setColor(color: CarColor): CarAppExtender.Builder

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

This method is equivalent to setColor for the car screen.

This color is only used for navigation notifications. See the "Navigation" section of CarAppExtender for more details.

Throws
java.lang.NullPointerException

if color is null

setContentIntent

Added in 1.0.0
fun setContentIntent(contentIntent: PendingIntent): CarAppExtender.Builder

Supplies a PendingIntent 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 setContentIntent for the car screen.

Parameters
contentIntent: PendingIntent

override for the notification's content intent.

Throws
java.lang.NullPointerException

if contentIntent is null

setContentText

Added in 1.0.0
fun setContentText(contentText: CharSequence): CarAppExtender.Builder

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

This method is equivalent to setContentText for the car screen.

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

Parameters
contentText: CharSequence

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
java.lang.NullPointerException

if contentText is null

setContentTitle

Added in 1.0.0
fun setContentTitle(contentTitle: CharSequence): CarAppExtender.Builder

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 setContentTitle for the car screen.

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

Throws
java.lang.NullPointerException

if contentTitle is null

setDeleteIntent

Added in 1.0.0
fun setDeleteIntent(deleteIntent: PendingIntent): CarAppExtender.Builder

Supplies a PendingIntent 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 setDeleteIntent for the car screen.

Parameters
deleteIntent: PendingIntent

override for the notification's delete intent

Throws
java.lang.NullPointerException

if deleteIntent is null

setImportance

Added in 1.0.0
fun setImportance(importance: Int): CarAppExtender.Builder

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

The default value is 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 NotificationManagerCompat for all supported importance values.

See also
setChannelId

setLargeIcon

Added in 1.0.0
fun setLargeIcon(bitmap: Bitmap): CarAppExtender.Builder

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 setLargeIcon for the car screen.

The large icon will be shown in the notification badge. If the large icon is not set in the CarAppExtender or the notification, the small icon will show instead.

Throws
java.lang.NullPointerException

if bitmap is null

setSmallIcon

Added in 1.0.0
fun setSmallIcon(iconResId: Int): CarAppExtender.Builder

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 setSmallIcon for the car screen.