public final class

CarAppExtender.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.car.app.notification.CarAppExtender.Builder

Overview

A builder of CarAppExtender.

Summary

Constructors
publicBuilder()

Creates an empty CarAppExtender.Builder instance.

Methods
public CarAppExtender.BuilderaddAction(int icon, java.lang.CharSequence title, PendingIntent intent)

Adds an action to this notification.

public CarAppExtenderbuild()

Constructs the CarAppExtender defined by this builder.

public CarAppExtender.BuildersetChannelId(java.lang.String channelId)

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

public CarAppExtender.BuildersetColor(CarColor color)

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

public CarAppExtender.BuildersetContentIntent(PendingIntent contentIntent)

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

public CarAppExtender.BuildersetContentText(java.lang.CharSequence contentText)

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

public CarAppExtender.BuildersetContentTitle(java.lang.CharSequence contentTitle)

Sets the title of the notification in the car screen.

public CarAppExtender.BuildersetDeleteIntent(PendingIntent deleteIntent)

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.

public CarAppExtender.BuildersetImportance(int importance)

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

public CarAppExtender.BuildersetLargeIcon(Bitmap bitmap)

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

public CarAppExtender.BuildersetSmallIcon(int iconResId)

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

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Creates an empty CarAppExtender.Builder instance.

Methods

public CarAppExtender.Builder setContentTitle(java.lang.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 for the car screen.

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

public CarAppExtender.Builder setContentText(java.lang.CharSequence contentText)

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

This method is equivalent to for the car screen.

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

Parameters:

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

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

public CarAppExtender.Builder setLargeIcon(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 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.

public CarAppExtender.Builder setContentIntent(PendingIntent contentIntent)

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

Parameters:

contentIntent: override for the notification's content intent.

public CarAppExtender.Builder setDeleteIntent(PendingIntent deleteIntent)

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

Parameters:

deleteIntent: override for the notification's delete intent

public CarAppExtender.Builder addAction(int icon, java.lang.CharSequence title, 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 one or more action is added with this method, any action added by will be ignored.

This method is equivalent to for the car screen.

Parameters:

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
title: text describing the action
intent: 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

public CarAppExtender.Builder setImportance(int importance)

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

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

See also: CarAppExtender.Builder.setChannelId(String)

public CarAppExtender.Builder setColor(CarColor color)

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

This method is equivalent to for the car screen.

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

public CarAppExtender.Builder setChannelId(java.lang.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 CarAppExtender.Builder.setImportance(int) for Auto.

See also: CarAppExtender.Builder.setImportance(int)

public CarAppExtender build()

Constructs the CarAppExtender defined by this builder.