CarExtender
class CarExtender : NotificationCompat.Extender
kotlin.Any | |
↳ | androidx.core.app.NotificationCompat.CarExtender |
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
add
andset
methods ofCarExtender
. - Call
androidx.core.app.NotificationCompat.Builder#extend(NotificationCompat.Extender)
to 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 classes | |
---|---|
A class which holds the unread messages from a conversation. |
Public constructors | |
---|---|
<init>() Create a |
|
<init>(@NonNull notification: Notification) Create a |
Public methods | |
---|---|
NotificationCompat.Builder |
extend(@NonNull builder: NotificationCompat.Builder) Apply car extensions to a notification that is being built. |
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? |
Returns the unread conversation conveyed by this notification. |
NotificationCompat.CarExtender |
Sets the accent color to use when Android Auto presents the notification. |
NotificationCompat.CarExtender |
setLargeIcon(@Nullable largeIcon: Bitmap?) Sets the large icon of the car notification. |
NotificationCompat.CarExtender |
setUnreadConversation(@Nullable unreadConversation: NotificationCompat.CarExtender.UnreadConversation?) Sets the unread conversation in a message notification. |
Public constructors
<init>
CarExtender(@NonNull notification: Notification)
Create a CarExtender
from the CarExtender options of an existing Notification.
Parameters | |
---|---|
notification |
Notification: The notification from which to copy options. |
Public methods
extend
@NonNull fun extend(@NonNull builder: NotificationCompat.Builder): NotificationCompat.Builder
Apply car extensions to a notification that is being built. This is typically called by the androidx.core.app.NotificationCompat.Builder#extend(NotificationCompat.Extender)
method of NotificationCompat.Builder
.
Parameters | |
---|---|
builder |
NotificationCompat.Builder: the builder to be modified. |
Return | |
---|---|
NotificationCompat.Builder |
the build object for chaining. |
getLargeIcon
@Nullable 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. |
See Also
getUnreadConversation
@Nullable fungetUnreadConversation(): NotificationCompat.CarExtender.UnreadConversation?
Deprecated: UnreadConversation
is no longer supported. Use MessagingStyle
instead.
Returns the unread conversation conveyed by this notification.
setColor
@NonNull fun setColor(@ColorInt color: Int): NotificationCompat.CarExtender
Sets the accent color to use when Android Auto presents the notification. Android Auto uses the color set with androidx.core.app.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.
setLargeIcon
@NonNull fun setLargeIcon(@Nullable 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 androidx.core.app.NotificationCompat.Builder#setLargeIcon(android.graphics.Bitmap)
Parameters | |
---|---|
largeIcon |
Bitmap?: The large icon to use in the car notification. |
Return | |
---|---|
NotificationCompat.CarExtender |
This object for method chaining. |
setUnreadConversation
@NonNull funsetUnreadConversation(@Nullable unreadConversation: NotificationCompat.CarExtender.UnreadConversation?): NotificationCompat.CarExtender
Deprecated: UnreadConversation
is no longer supported. Use MessagingStyle
instead.
Sets the unread conversation in a message notification.
Parameters | |
---|---|
unreadConversation |
NotificationCompat.CarExtender.UnreadConversation?: The unread part of the conversation this notification conveys. |
Return | |
---|---|
NotificationCompat.CarExtender |
This object for method chaining. |