NotificationCompat.CarExtender

public static final class NotificationCompat.CarExtender
extends Object implements NotificationCompat.Extender

java.lang.Object
   ↳ androidx.core.app.NotificationCompat.CarExtender


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

Nested classes

class NotificationCompat.CarExtender.UnreadConversation

This class is deprecated. NotificationCompat.CarExtender.UnreadConversation is no longer supported. Use NotificationCompat.MessagingStyle instead.  

Public constructors

CarExtender()

Create a NotificationCompat.CarExtender with default options.

CarExtender(Notification notification)

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

Public methods

NotificationCompat.Builder extend(NotificationCompat.Builder builder)

Apply car extensions to a notification that is being built.

int getColor()

Gets the accent color.

Bitmap getLargeIcon()

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

NotificationCompat.CarExtender.UnreadConversation getUnreadConversation()

This method is deprecated. NotificationCompat.CarExtender.UnreadConversation is no longer supported. Use NotificationCompat.MessagingStyle instead.

NotificationCompat.CarExtender setColor(int color)

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

NotificationCompat.CarExtender setLargeIcon(Bitmap largeIcon)

Sets the large icon of the car notification.

NotificationCompat.CarExtender setUnreadConversation(NotificationCompat.CarExtender.UnreadConversation unreadConversation)

This method is deprecated. NotificationCompat.CarExtender.UnreadConversation is no longer supported. Use NotificationCompat.MessagingStyle instead.

Inherited methods

Public constructors

CarExtender

public CarExtender ()

Create a NotificationCompat.CarExtender with default options.

CarExtender

public CarExtender (Notification notification)

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

Parameters
notification Notification: The notification from which to copy options.

Public methods

extend

public NotificationCompat.Builder extend (NotificationCompat.Builder builder)

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.

Parameters
builder NotificationCompat.Builder: the builder to be modified.

Returns
NotificationCompat.Builder the build object for chaining.

getColor

public int getColor ()

Gets the accent color.

Returns
int

See also:

getLargeIcon

public Bitmap getLargeIcon ()

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

Returns