Most visited

Recently visited

NotificationCompat.CarExtender

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

java.lang.Object
    android.support.v4.app.NotificationCompat.CarExtender


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

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

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

摘要(Summary)

Nested classes

class NotificationCompat.CarExtender.UnreadConversation

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

Public constructors

NotificationCompat.CarExtender()

使用默认选项创建 NotificationCompat.CarExtender

NotificationCompat.CarExtender(Notification notif)

从现有通知的CarExtender选项创建 NotificationCompat.CarExtender

公共方法(Public methods)

NotificationCompat.Builder extend(NotificationCompat.Builder builder)

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

int getColor()

获取重音颜色。

Bitmap getLargeIcon()

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

NotificationCompat.CarExtender.UnreadConversation getUnreadConversation()

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

NotificationCompat.CarExtender setColor(int color)

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

NotificationCompat.CarExtender setLargeIcon(Bitmap largeIcon)

设置汽车通知的大图标。

NotificationCompat.CarExtender setUnreadConversation(NotificationCompat.CarExtender.UnreadConversation unreadConversation)

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

继承方法(Inherited methods)

From class java.lang.Object
From interface android.support.v4.app.NotificationCompat.Extender

Public constructors

NotificationCompat.CarExtender

NotificationCompat.CarExtender ()

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

NotificationCompat.CarExtender

NotificationCompat.CarExtender (Notification notif)

从现有通知的CarExtender选项创建 NotificationCompat.CarExtender

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

公共方法(Public methods)

extend

NotificationCompat.Builder extend (NotificationCompat.Builder builder)

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

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

getColor

int getColor ()

获取重音颜色。

返回(Returns)
int

也可以看看:

getLargeIcon

Bitmap getLargeIcon ()

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

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

也可以看看:

getUnreadConversation

NotificationCompat.CarExtender.UnreadConversation getUnreadConversation ()

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

返回(Returns)
NotificationCompat.CarExtender.UnreadConversation

也可以看看:

setColor

NotificationCompat.CarExtender setColor (int color)

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

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

setLargeIcon

NotificationCompat.CarExtender setLargeIcon (Bitmap largeIcon)

设置汽车通知的大图标。 如果扩展器中没有设置大图标,Android Auto将显示setLargeIcon(android.graphics.Bitmap)指定的图标

参数(Parameters)
largeIcon Bitmap: The large icon to use in the car notification.
返回(Returns)
NotificationCompat.CarExtender This object for method chaining.

setUnreadConversation

NotificationCompat.CarExtender setUnreadConversation (NotificationCompat.CarExtender.UnreadConversation unreadConversation)

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

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

Hooray!