public final class

NotificationCompat.CarExtender

extends java.lang.Object

implements NotificationCompat.Extender

 java.lang.Object

↳androidx.core.app.NotificationCompat.CarExtender

Overview

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

  1. Create an NotificationCompat.Builder, setting any desired properties.
  2. Create a NotificationCompat.CarExtender.
  3. Set car-specific properties using the add and set methods of NotificationCompat.CarExtender.
  4. Call NotificationCompat.Builder.extend(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.
 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

Constructors
publicCarExtender()

Create a NotificationCompat.CarExtender with default options.

publicCarExtender(Notification notification)

Create a NotificationCompat.CarExtender from the CarExtender options of an existing Notification.

Methods
public NotificationCompat.Builderextend(NotificationCompat.Builder builder)

Apply car extensions to a notification that is being built.

public intgetColor()

Gets the accent color.

public BitmapgetLargeIcon()

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

public NotificationCompat.CarExtender.UnreadConversationgetUnreadConversation()

Returns the unread conversation conveyed by this notification.

public NotificationCompat.CarExtendersetColor(int color)

Sets the accent color to use when Android Auto presents the notification.

public NotificationCompat.CarExtendersetLargeIcon(Bitmap largeIcon)

Sets the large icon of the car notification.

public NotificationCompat.CarExtendersetUnreadConversation(NotificationCompat.CarExtender.UnreadConversation unreadConversation)

Sets the unread conversation in a message notification.

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

Constructors

public CarExtender()

Create a NotificationCompat.CarExtender with default options.

public CarExtender(Notification notification)

Create a NotificationCompat.CarExtender from the CarExtender options of an existing Notification.

Parameters:

notification: The notification from which to copy options.

Methods

Apply car extensions to a notification that is being built. This is typically called by the NotificationCompat.Builder.extend(NotificationCompat.Extender) method of NotificationCompat.Builder.

public NotificationCompat.CarExtender setColor(int color)

Sets the accent color to use when Android Auto presents the notification. Android Auto uses the color set with 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.

public int getColor()

Gets the accent color.

See also: NotificationCompat.CarExtender.setColor(int)

public NotificationCompat.CarExtender setLargeIcon(Bitmap largeIcon)

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 NotificationCompat.Builder

Parameters:

largeIcon: The large icon to use in the car notification.

Returns:

This object for method chaining.

public Bitmap getLargeIcon()

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

Returns:

The large icon for the car notification.

See also: NotificationCompat.CarExtender.setLargeIcon(Bitmap)

Deprecated: NotificationCompat.CarExtender.UnreadConversation is no longer supported. Use NotificationCompat.MessagingStyle instead.

Sets the unread conversation in a message notification.

Parameters:

unreadConversation: The unread part of the conversation this notification conveys.

Returns:

This object for method chaining.

Deprecated: NotificationCompat.CarExtender.UnreadConversation is no longer supported. Use NotificationCompat.MessagingStyle instead.

Returns the unread conversation conveyed by this notification.

See also: NotificationCompat.CarExtender.setUnreadConversation(NotificationCompat.CarExtender.UnreadConversation)