public static final class NotificationCompat.CarExtender extends Object implements NotificationCompat.Extender
Helper class to add Android Auto extensions to notifications. To create a notification with car extensions:
NotificationCompat.Builder
, setting any desired
properties.
NotificationCompat.CarExtender
.
add
and set
methods of
NotificationCompat.CarExtender
.
NotificationCompat.Builder.extend(NotificationCompat.Extender)
to apply the extensions to a notification.
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.
Modifier and Type | Class and Description |
---|---|
static class |
NotificationCompat.CarExtender.UnreadConversation
A class which holds the unread messages from a conversation.
|
Constructor and Description |
---|
CarExtender()
Create a
NotificationCompat.CarExtender with default options. |
CarExtender(Notification notif)
Create a
NotificationCompat.CarExtender from the CarExtender options of an existing Notification. |
Modifier and Type | Method and Description |
---|---|
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()
Returns the unread conversation conveyed by this notification.
|
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)
Sets the unread conversation in a message notification.
|
public CarExtender()
NotificationCompat.CarExtender
with default options.public CarExtender(Notification notif)
NotificationCompat.CarExtender
from the CarExtender options of an existing Notification.notif
- The notification from which to copy options.public NotificationCompat.Builder extend(NotificationCompat.Builder builder)
NotificationCompat.Builder.extend(NotificationCompat.Extender)
method of NotificationCompat.Builder
.extend
in interface NotificationCompat.Extender
builder
- the builder to be modified.public NotificationCompat.CarExtender setColor(int color)
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()
setColor(int)
public NotificationCompat.CarExtender setLargeIcon(Bitmap largeIcon)
NotificationCompat.Builder.setLargeIcon(android.graphics.Bitmap)
largeIcon
- The large icon to use in the car notification.public Bitmap getLargeIcon()
setLargeIcon(android.graphics.Bitmap)
public NotificationCompat.CarExtender setUnreadConversation(NotificationCompat.CarExtender.UnreadConversation unreadConversation)
unreadConversation
- The unread part of the conversation this notification conveys.public NotificationCompat.CarExtender.UnreadConversation getUnreadConversation()