Android APIs
public static final class

Notification.CarExtender

extends Object
implements Notification.Extender
java.lang.Object
   ↳ android.app.Notification.CarExtender

Class Overview

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

  1. Create an Notification.Builder, setting any desired properties.
  2. Create a Notification.CarExtender.
  3. Set car-specific properties using the add and set methods of Notification.CarExtender.
  4. Call extend(Notification.Extender) to apply the extensions to a notification.
 Notification notification = new Notification.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 Notification.CarExtender.Builder Builder class for Notification.CarExtender.UnreadConversation objects. 
class Notification.CarExtender.UnreadConversation A class which holds the unread messages from a conversation. 
Public Constructors
Notification.CarExtender()
Create a Notification.CarExtender with default options.
Notification.CarExtender(Notification notif)
Create a Notification.CarExtender from the CarExtender options of an existing Notification.
Public Methods
Notification.Builder extend(Notification.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.
Notification.CarExtender.UnreadConversation getUnreadConversation()
Returns the unread conversation conveyed by this notification.
Notification.CarExtender setColor(int color)
Sets the accent color to use when Android Auto presents the notification.
Notification.CarExtender setLargeIcon(Bitmap largeIcon)
Sets the large icon of the car notification.
Notification.CarExtender setUnreadConversation(Notification.CarExtender.UnreadConversation unreadConversation)
Sets the unread conversation in a message notification.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.app.Notification.Extender

Public Constructors

public Notification.CarExtender ()

Added in API level 23

Create a Notification.CarExtender with default options.

public Notification.CarExtender (Notification notif)

Added in API level 23

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

Parameters
notif The notification from which to copy options.

Public Methods

public Notification.Builder extend (Notification.Builder builder)

Added in API level 23

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

Parameters
builder the builder to be modified.
Returns
  • the build object for chaining.

public int getColor ()

Added in API level 23

Gets the accent color.

See Also

public Bitmap getLargeIcon ()

Added in API level 23

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.

public Notification.CarExtender.UnreadConversation getUnreadConversation ()

Added in API level 23

Returns the unread conversation conveyed by this notification.

public Notification.CarExtender setColor (int color)

Added in API level 23

Sets the accent color to use when Android Auto presents the notification. Android Auto uses the color set with 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 Notification.CarExtender setLargeIcon (Bitmap largeIcon)

Added in API level 23

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 setLargeIcon(android.graphics.Bitmap)

Parameters
largeIcon The large icon to use in the car notification.
Returns
  • This object for method chaining.

public Notification.CarExtender setUnreadConversation (Notification.CarExtender.UnreadConversation unreadConversation)

Added in API level 23

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.