NotificationCompat.CarExtender
class NotificationCompat.CarExtender : NotificationCompat.Extender
Helper class to add Android Auto extensions to notifications. To create a notification with car extensions:
- Create an
NotificationCompat.Builder, setting any desired properties. - Create a
CarExtender. - Set car-specific properties using the
addandsetmethods ofCarExtender. - Call
extendto apply the extensions to a notification. - Post the notification to the notification system with the
NotificationManagerCompat.notify(...)methods and not theNotificationManager.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 types |
|---|
|
This class is deprecated.
|
|
Builder class for |
Public constructors |
|---|
|
Create a |
CarExtender(notification: Notification)Create a |
Public functions |
|
|---|---|
NotificationCompat.Builder |
extend(builder: NotificationCompat.Builder)Apply car extensions to a notification that is being built. |
@ColorInt Int |
getColor()Gets the accent color. |
Bitmap? |
Gets the large icon used in this car notification, or null if no icon has been set. |
NotificationCompat.CarExtender.UnreadConversation? |
This function is deprecated.
|
NotificationCompat.CarExtender |
Sets the accent color to use when Android Auto presents the notification. |
NotificationCompat.CarExtender |
setLargeIcon(largeIcon: Bitmap?)Sets the large icon of the car notification. |
NotificationCompat.CarExtender |
This function is deprecated.
|
Public constructors
CarExtender
CarExtender(notification: Notification)
Create a CarExtender from the CarExtender options of an existing Notification.
| Parameters | |
|---|---|
notification: Notification |
The notification from which to copy options. |
Public functions
extend
fun extend(builder: NotificationCompat.Builder): NotificationCompat.Builder
Apply car extensions to a notification that is being built. This is typically called by the extend method of NotificationCompat.Builder.
getLargeIcon
fun getLargeIcon(): Bitmap?
Gets the large icon used in this car notification, or null if no icon has been set.
| Returns | |
|---|---|
Bitmap? |
The large icon for the car notification. |
| See also | |
|---|---|
setLargeIcon |
fungetUnreadConversation(): NotificationCompat.CarExtender.UnreadConversation?
Returns the unread conversation conveyed by this notification.
| See also | |
|---|---|
setUnreadConversation |
setColor
fun setColor(color: @ColorInt Int): NotificationCompat.CarExtender
Sets the accent color to use when Android Auto presents the notification. Android Auto uses the color set with setColor 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
fun setLargeIcon(largeIcon: Bitmap?): NotificationCompat.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 setLargeIcon
| Parameters | |
|---|---|
largeIcon: Bitmap? |
The large icon to use in the car notification. |
| Returns | |
|---|---|
NotificationCompat.CarExtender |
This object for method chaining. |
funsetUnreadConversation(
unreadConversation: NotificationCompat.CarExtender.UnreadConversation?
): NotificationCompat.CarExtender
Sets the unread conversation in a message notification.
| Parameters | |
|---|---|
unreadConversation: NotificationCompat.CarExtender.UnreadConversation? |
The unread part of the conversation this notification conveys. |
| Returns | |
|---|---|
NotificationCompat.CarExtender |
This object for method chaining. |