Sequenceablepublic static final class NotificationRequest.NotificationConversationalContent extends Object implements Sequenceable
When constructing a conversation-like notification, you need to call
NotificationRequest#setContent(NotificationContent) to set the corresponding notification content type.
You can call setConversationTitle(java.lang.String) to set the title for the conversation and
addConversationalMessage(ohos.event.notification.NotificationRequest.NotificationConversationalContent.ConversationalMessage) to add messages included in the conversation.
The title and messages set using these two methods will affect the display effect of the title and text
set by calling setTitle(java.lang.String)
and setText(java.lang.String), respectively.
SystemCapability.Notification#ANS| 限定符和类型 | 类 | 说明 |
|---|---|---|
static class |
NotificationRequest.NotificationConversationalContent.ConversationalMessage |
Provides methods for defining a conversational message that is used in notifications created with
NotificationConversationalContent. |
Sequenceable.Producer<T>| 构造器 | 说明 |
|---|---|
NotificationConversationalContent(MessageUser user) |
A constructor used to create a
NotificationConversationalContent instance with the
MessageUser specified. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
NotificationRequest.NotificationConversationalContent |
addConversationalMessage(String text,
long timestamp,
MessageUser sender) |
Adds a message to this conversation-like notification based on the specified message content, timestamp,
and
MessageUser. |
NotificationRequest.NotificationConversationalContent |
addConversationalMessage(NotificationRequest.NotificationConversationalContent.ConversationalMessage message) |
Adds a specified message to this conversation-like notification.
|
String |
getAdditionalText() |
Obtains the additional text that has been set by calling
setAdditionalText(java.lang.String) for this
conversation-like notification. |
List<NotificationRequest.NotificationConversationalContent.ConversationalMessage> |
getAllConversationalMessages() |
Obtains all messages included in this conversation-like notification.
|
String |
getConversationTitle() |
Obtains the title to be displayed for the conversation.
|
MessageUser |
getMessageUser() |
Obtains the message sender to be displayed for any messages sent by the user in this
conversation-like notification.
|
String |
getText() |
Obtains the notification content that has been set by calling
setText(java.lang.String) for this
conversation-like notification. |
String |
getTitle() |
Obtains the title that has been set by calling
setTitle(java.lang.String) for this
conversation-like notification. |
boolean |
isConversationGroup() |
Checks whether this notification represents a group conversation.
|
boolean |
marshalling(Parcel out) |
Marshals this
NotificationConversationalContent object into a Parcel. |
NotificationRequest.NotificationConversationalContent |
setAdditionalText(String additionalText) |
Sets the additional text to be included in this conversation-like notification.
|
NotificationRequest.NotificationConversationalContent |
setConversationGroup(boolean conversationGroup) |
Sets whether this notification represents a group conversation.
|
NotificationRequest.NotificationConversationalContent |
setConversationTitle(String conversationTitle) |
Sets the title to be displayed for the conversation.
|
NotificationRequest.NotificationConversationalContent |
setText(String text) |
Sets the text to be included in this conversation-like notification.
|
NotificationRequest.NotificationConversationalContent |
setTitle(String title) |
Sets the title of this conversation-like notification.
|
String |
toString() |
Returns a string representation of the object.
|
boolean |
unmarshalling(Parcel in) |
Unmarshals this
NotificationConversationalContent object from a Parcel. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waithasFileDescriptorpublic NotificationConversationalContent(MessageUser user) throws IllegalArgumentException
NotificationConversationalContent instance with the
MessageUser specified.user - Indicates the MessageUser who sends all Message objects in this
conversation-like notification. This parameter cannot be null.IllegalArgumentException - Throws this exception if user is null.public MessageUser getMessageUser()
public String getTitle()
setTitle(java.lang.String) for this
conversation-like notification.
If setConversationTitle(java.lang.String) is called together with
addConversationalMessage(ohos.event.notification.NotificationRequest.NotificationConversationalContent.ConversationalMessage) or
addConversationalMessage(java.lang.String,long,ohos.event.notification.MessageUser) for this notification, the return value of
this method will be a combination of the return value of getConversationTitle() and that of
MessageUser#getName() called on the MessageUser of the last added Message.
public NotificationRequest.NotificationConversationalContent setTitle(String title)
title - Indicates the title of this conversation-like notification.NotificationConversationalContent object.public String getText()
setText(java.lang.String) for this
conversation-like notification.
If addConversationalMessage(ohos.event.notification.NotificationRequest.NotificationConversationalContent.ConversationalMessage) or
addConversationalMessage(java.lang.String,long,ohos.event.notification.MessageUser) is also
called for this notification, the return value of this method will be the return value of
ConversationalMessage#getText() called on the last added Message.
public NotificationRequest.NotificationConversationalContent setText(String text)
setConversationTitle(java.lang.String) is also called for this notification.text - Indicates the text to be included.NotificationConversationalContent object.public String getAdditionalText()
setAdditionalText(java.lang.String) for this
conversation-like notification.public NotificationRequest.NotificationConversationalContent setAdditionalText(String additionalText)
The additional text is a supplement to the notification text set by calling setText(java.lang.String).
The font of the additional text is smaller than the notification text and is displayed in a separate line.
additionalText - Indicates the additional text to be included.NotificationConversationalContent object.public String getConversationTitle()
public NotificationRequest.NotificationConversationalContent setConversationTitle(String conversationTitle)
The title set in this method will overwrite the one set by calling setTitle(java.lang.String).
conversationTitle - Indicates the title to be displayed for the conversation.NotificationConversationalContent object.public boolean isConversationGroup()
true if this notification represents a group conversation; returns
false otherwise.public NotificationRequest.NotificationConversationalContent setConversationGroup(boolean conversationGroup)
The big icon, if any, set for this notification by calling
NotificationRequest#setBigIcon(PixelMap) will be displayed only when
this method is set to true.
conversationGroup - Specifies whether this notification represents a group conversation.
The value true indicates a group conversation, and the value false indicates not.NotificationConversationalContent object.public List<NotificationRequest.NotificationConversationalContent.ConversationalMessage> getAllConversationalMessages()
Message objects included.public NotificationRequest.NotificationConversationalContent addConversationalMessage(NotificationRequest.NotificationConversationalContent.ConversationalMessage message)
message - Indicates the ConversationalMessage object to add.NotificationConversationalContent object.public NotificationRequest.NotificationConversationalContent addConversationalMessage(String text, long timestamp, MessageUser sender) throws IllegalArgumentException
MessageUser. All messages will be displayed in the order they are added.text - Indicates the text to be displayed as the message content. This parameter cannot be null.timestamp - Indicates the time when the message arrived.sender - Indicates the MessageUser who sent the message.NotificationConversationalContent object.IllegalArgumentException - Throws this exception if text is null.public boolean marshalling(Parcel out)
NotificationConversationalContent object into a Parcel.
A process can call the unmarshalling(ohos.utils.Parcel) method to unmarshal this
NotificationConversationalContent object from a Parcel to implement
inter-process communication (IPC).
marshalling 在接口中 Sequenceableout - Indicates the Parcel object for marshalling.true if the marshalling is successful; returns false otherwise.public boolean unmarshalling(Parcel in)
NotificationConversationalContent object from a Parcel.unmarshalling 在接口中 Sequenceablein - Indicates the Parcel object for unmarshalling.true if the unmarshalling is successful; returns false otherwise.public String toString()
ObjecttoString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())