Notification.CarExtender
public
static
final
class
Notification.CarExtender
extends Object
implements
Notification.Extender
java.lang.Object | |
↳ | android.app.Notification.CarExtender |
Helper class to add Android Auto extensions to notifications. To create a notification with car extensions:
- Create an
Notification.Builder
, setting any desired properties. - Create a
CarExtender
. - Set car-specific properties using the
add
andset
methods ofCarExtender
. - 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 | |
---|---|
class |
Notification.CarExtender.Builder
Builder class for |
class |
Notification.CarExtender.UnreadConversation
A class which holds the unread messages from a conversation. |
Public constructors | |
---|---|
CarExtender()
Create a |
|
CarExtender(Notification notif)
Create a |
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. |
Inherited methods | |
---|---|
Public constructors
CarExtender
public CarExtender (Notification notif)
Create a CarExtender
from the CarExtender options of an existing Notification.
Parameters | |
---|---|
notif |
Notification : The notification from which to copy options. |
Public methods
extend
public Notification.Builder extend (Notification.Builder 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. |
Returns | |
---|---|
Notification.Builder |
the build object for chaining. |
getLargeIcon
public Bitmap getLargeIcon ()
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:
getUnreadConversation
public Notification.CarExtender.UnreadConversation getUnreadConversation ()
Returns the unread conversation conveyed by this notification.
Returns | |
---|---|
Notification.CarExtender.UnreadConversation |
setColor
public Notification.CarExtender setColor (int color)
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.
Parameters | |
---|---|
color |
int |
Returns | |
---|---|
Notification.CarExtender |
setLargeIcon
public Notification.CarExtender setLargeIcon (Bitmap largeIcon)
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. |
Returns | |
---|---|
Notification.CarExtender |
This object for method chaining. |
setUnreadConversation
public Notification.CarExtender setUnreadConversation (Notification.CarExtender.UnreadConversation unreadConversation)
Sets the unread conversation in a message notification.
Parameters | |
---|---|
unreadConversation |
Notification.CarExtender.UnreadConversation : The unread part of the conversation this notification conveys. |
Returns | |
---|---|
Notification.CarExtender |
This object for method chaining. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-12-18 UTC.