Added in API level 23

CarExtender


class CarExtender : Notification.Extender
kotlin.Any
   ↳ android.app.Notification.CarExtender

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 CarExtender.
  3. Set car-specific properties using the add and set methods of CarExtender.
  4. Call Notification.Builder#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

Builder class for CarExtender.UnreadConversation objects.

A class which holds the unread messages from a conversation.

Public constructors

Create a CarExtender with default options.

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

Public methods
Notification.Builder!

Apply car extensions to a notification that is being built.

Int

Gets the accent color.

Bitmap!

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

Notification.CarExtender.UnreadConversation!

Returns the unread conversation conveyed by this notification.

Notification.CarExtender!
setColor(color: Int)

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

Notification.CarExtender!
setLargeIcon(largeIcon: Bitmap!)

Sets the large icon of the car notification.

Notification.CarExtender!

Sets the unread conversation in a message notification.

Public constructors

CarExtender

Added in API level 23
CarExtender()

Create a CarExtender with default options.

CarExtender

Added in API level 23
CarExtender(notif: Notification!)

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

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

Public methods

extend

Added in API level 23
fun extend(builder: Notification.Builder!): Notification.Builder!

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

Parameters
builder Notification.Builder!: the builder to be modified.
Return
Notification.Builder! the build object for chaining.

getColor

Added in API level 23
fun getColor(): Int

Gets the accent color.

See Also

getLargeIcon

Added in API level 23
fun getLargeIcon(): Bitmap!

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

Return
Bitmap! The large icon for the car notification.

getUnreadConversation

Added in API level 23
fun getUnreadConversation(): Notification.CarExtender.UnreadConversation!

Returns the unread conversation conveyed by this notification.

setColor

Added in API level 23
fun setColor(color: Int): Notification.CarExtender!

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

setLargeIcon

Added in API level 23
fun setLargeIcon(largeIcon: Bitmap!): Notification.CarExtender!

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

Parameters
largeIcon Bitmap!: The large icon to use in the car notification.
Return
Notification.CarExtender! This object for method chaining.

setUnreadConversation

Added in API level 23
fun setUnreadConversation(unreadConversation: Notification.CarExtender.UnreadConversation!): Notification.CarExtender!

Sets the unread conversation in a message notification.

Parameters
unreadConversation Notification.CarExtender.UnreadConversation!: The unread part of the conversation this notification conveys.
Return
Notification.CarExtender! This object for method chaining.