Most visited

Recently visited

NotificationCompat.MessagingStyle

public static class NotificationCompat.MessagingStyle
extends NotificationCompat.Style

java.lang.Object
   ↳ android.support.v4.app.NotificationCompat.Style
     ↳ android.support.v4.app.NotificationCompat.MessagingStyle


Helper类用于生成包含多个不同类型的多个来回消息的大格式通知。
如果平台不提供大幅面通知,则此方法不起作用。 用户将始终看到正常的通知视图。
这个类是一个“重建器”:它附着到一个Builder对象并修改它的行为,如下所示:


 Notification noti = new Notification.Builder()
     .setContentTitle("2 new messages wtih " + sender.toString())
     .setContentText(subject)
     .setSmallIcon(R.drawable.new_message)
     .setLargeIcon(aBitmap)
     .setStyle(new Notification.MessagingStyle(resources.getString(R.string.reply_name))
         .addMessage(messages[0].getText(), messages[0].getTime(), messages[0].getSender())
         .addMessage(messages[1].getText(), messages[1].getTime(), messages[1].getSender()))
     .build();
 

Summary

Nested classes

class NotificationCompat.MessagingStyle.Message

 

Constants

int MAXIMUM_RETAINED_MESSAGES

通知本身将保留的最大消息数(显示的数字取决于平台)。

Public constructors

NotificationCompat.MessagingStyle(CharSequence userDisplayName)

Public methods

void addCompatExtras(Bundle extras)
NotificationCompat.MessagingStyle addMessage(CharSequence text, long timestamp, CharSequence sender)

添加此通知显示的消息。

NotificationCompat.MessagingStyle addMessage(NotificationCompat.MessagingStyle.Message message)

在此通知中添加 NotificationCompat.MessagingStyle.Message以供显示。

static NotificationCompat.MessagingStyle extractMessagingStyleFromNotification(Notification notif)

检索 NotificationCompat.MessagingStyleNotification ,使已设定的应用程序 NotificationCompat.MessagingStyle使用 NotificationCompatNotification.Builder到消息信息发送到使用另一应用程序 NotificationCompat ,不论该系统的API级的。

CharSequence getConversationTitle()

返回要在此对话中显示的标题。

List<NotificationCompat.MessagingStyle.Message> getMessages()

获取表示通知的 Message对象的列表

CharSequence getUserDisplayName()

返回用户发送的任何回复的名称

NotificationCompat.MessagingStyle setConversationTitle(CharSequence conversationTitle)

设置要在此对话中显示的标题。

Inherited methods

From class android.support.v4.app.NotificationCompat.Style
From class java.lang.Object

Constants

MAXIMUM_RETAINED_MESSAGES

int MAXIMUM_RETAINED_MESSAGES

通知本身将保留的最大消息数(显示的数字取决于平台)。

常量值:25(0x00000019)

Public constructors

NotificationCompat.MessagingStyle

NotificationCompat.MessagingStyle (CharSequence userDisplayName)

Parameters
userDisplayName CharSequence: the name to be displayed for any replies sent by the user before the posting app reposts the notification with those messages after they've been actually sent and in previous messages sent by the user added in addMessage(Message)

Public methods

addCompatExtras

void addCompatExtras (Bundle extras)

Parameters
extras Bundle

addMessage

NotificationCompat.MessagingStyle addMessage (CharSequence text, 
                long timestamp, 
                CharSequence sender)

添加此通知显示的消息。 方便的调用,一个简单NotificationCompat.MessagingStyle.MessageaddMessage(Message)

Parameters
text CharSequence: A CharSequence to be displayed as the message content
timestamp long: Time at which the message arrived
sender CharSequence: A CharSequence to be used for displaying the name of the sender. Should be null for messages by the current user, in which case the platform will insert getUserDisplayName(). Should be unique amongst all individuals in the conversation, and should be consistent during re-posts of the notification.
Returns
NotificationCompat.MessagingStyle this object for method chaining

也可以看看:

addMessage

NotificationCompat.MessagingStyle addMessage (NotificationCompat.MessagingStyle.Message message)

在此通知中添加 NotificationCompat.MessagingStyle.Message以供显示。

Parameters
message NotificationCompat.MessagingStyle.Message: The NotificationCompat.MessagingStyle.Message to be displayed
Returns
NotificationCompat.MessagingStyle this object for method chaining

extractMessagingStyleFromNotification

NotificationCompat.MessagingStyle extractMessagingStyleFromNotification (Notification notif)

检索NotificationCompat.MessagingStyleNotification ,使已设定的应用程序NotificationCompat.MessagingStyle使用NotificationCompatNotification.Builder到消息信息发送到使用另一应用程序NotificationCompat ,不论该系统的API级的。 返回null如果没有NotificationCompat.MessagingStyle集。

Parameters
notif Notification
Returns
NotificationCompat.MessagingStyle

getConversationTitle

CharSequence getConversationTitle ()

返回要在此对话中显示的标题。 可以是null ,应该用于一对一的对话

Returns
CharSequence

getMessages

List<NotificationCompat.MessagingStyle.Message> getMessages ()

获取表示通知的 Message对象的列表

Returns
List<NotificationCompat.MessagingStyle.Message>

getUserDisplayName

CharSequence getUserDisplayName ()

返回用户发送的任何回复的名称

Returns
CharSequence

setConversationTitle

NotificationCompat.MessagingStyle setConversationTitle (CharSequence conversationTitle)

设置要在此对话中显示的标题。 这应该只用于群组消息,并且不会进行一对一对话。

Returns
NotificationCompat.MessagingStyle this object for method chaining.

Hooray!