Most visited

Recently visited

Added in API level 23

Notification.CarExtender

public static final class Notification.CarExtender
extends Object implements Notification.Extender

java.lang.Object
    android.app.Notification.CarExtender


Helper类将Android Auto扩展添加到通知。 使用附加车辆信息创建通知:

  1. Create an Notification.Builder, setting any desired properties.
  2. Create a Notification.CarExtender.
  3. Set car-specific properties using the add and set methods of Notification.CarExtender.
  4. Call extend(Notification.Extender) to apply the extensions to a notification.
 Notification notification = new Notification.Builder(context)
         ...
         .extend(new CarExtender()
                 .set*(...))
         .build();
 

通过使用 CarExtender(Notification)构造函数,然后使用 get方法访问值,可以在现有通知上访问车辆扩展。

摘要(Summary)

Nested classes

class Notification.CarExtender.Builder

Notification.CarExtender.UnreadConversation对象的生成器类。

class Notification.CarExtender.UnreadConversation

一个保存来自对话的未读消息的类。

Public constructors

Notification.CarExtender()

使用默认选项创建一个 Notification.CarExtender

Notification.CarExtender(Notification notif)

从现有通知的CarExtender选项创建一个 Notification.CarExtender

公共方法(Public methods)

Notification.Builder extend(Notification.Builder builder)

将车辆扩展应用于正在构建的通知。

int getColor()

获取重音颜色。

Bitmap getLargeIcon()

获取本车通知中使用的大图标,如果没有设置图标,则返回null。

Notification.CarExtender.UnreadConversation getUnreadConversation()

返回此通知传送的未读对话。

Notification.CarExtender setColor(int color)

设置Android Auto提示通知时使用的重音颜色。

Notification.CarExtender setLargeIcon(Bitmap largeIcon)

设置汽车通知的大图标。

Notification.CarExtender setUnreadConversation(Notification.CarExtender.UnreadConversation unreadConversation)

在消息通知中设置未读对话。

继承方法(Inherited methods)

From class java.lang.Object
From interface android.app.Notification.Extender

Public constructors

Notification.CarExtender

Added in API level 23
Notification.CarExtender ()

使用默认选项创建一个 Notification.CarExtender

Notification.CarExtender

Added in API level 23
Notification.CarExtender (Notification notif)

从现有通知的CarExtender选项创建一个 Notification.CarExtender

参数(Parameters)
notif Notification: The notification from which to copy options.

公共方法(Public methods)

extend

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

将车辆扩展应用于正在构建的通知。 这通常由extend(Notification.Extender)方法Notification.Builder

参数(Parameters)
builder Notification.Builder: the builder to be modified.
返回(Returns)
Notification.Builder the build object for chaining.

getColor

Added in API level 23
int getColor ()

获取重音颜色。

返回(Returns)
int

也可以看看:

getLargeIcon

Added in API level 23
Bitmap getLargeIcon ()

获取本车通知中使用的大图标,如果没有设置图标,则返回null。

返回(Returns)
Bitmap The large icon for the car notification.

也可以看看:

getUnreadConversation

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

返回此通知传送的未读对话。

返回(Returns)
Notification.CarExtender.UnreadConversation

也可以看看:

setColor

Added in API level 23
Notification.CarExtender setColor (int color)

设置Android Auto提示通知时使用的重音颜色。 Android Auto使用与setColor(int)一起设置的颜色强调显示的通知。 然而,在汽车环境中并非所有颜色都可以接受。 在这种情况下,此方法可用于覆盖通知中提供的颜色。

参数(Parameters)
color int
返回(Returns)
Notification.CarExtender

setLargeIcon

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

设置汽车通知的大图标。 如果扩展器中没有设置大图标,Android Auto会显示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

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

在消息通知中设置未读对话。

参数(Parameters)
unreadConversation Notification.CarExtender.UnreadConversation: The unread part of the conversation this notification conveys.
返回(Returns)
Notification.CarExtender This object for method chaining.

Hooray!