树叶云鸿蒙OS教程:鸿蒙OS NotificationRequest.NotificationConversationalContent

NotificationRequest.NotificationConversationalContent

java.lang.Object

|—ohos.event.notification.NotificationRequest.NotificationConversationalContent

public static final class NotificationRequest.NotificationConversationalContent
extends Object
implements Sequenceable

构造一个类似对话的通知,其中包括多个用户之间的消息通信。

构造类会话通知时,需要调用 NotificationRequest#setContent(NotificationContent) 设置对应的通知内容类型。 您可以调用 setConversationTitle(java.lang.String) 来设置对话的标题,并调用 addConversationalMessage(ohos.event.notification.NotificationRequest.NotificationConversationalContent.ConversationalMessage) 来添加包含在对话中的消息。 使用这两种方法设置的标题和消息会影响分别调用 setTitle(java.lang.String) 和 setText(java.lang.String) 设置的标题和文本的显示效果。

Since:

3

嵌套类摘要

修饰符和类型描述
static classNotificationRequest.NotificationConversationalContent.ConversationalMessage提供用于定义在使用 NotificationConversationalContent 创建的通知中使用的会话消息的方法。
从接口 ohos.utils.Sequenceable 继承的嵌套类/接口
Sequenceable.ProducerT

构造函数摘要

构造函数描述
NotificationConversationalContent(MessageUser user)用于创建具有指定 MessageUser 的 NotificationConversationalContent 实例的构造函数。

方法总结

修饰符和类型方法描述
NotificationRequest.NotificationConversationalContentaddConversationalMessage(String text, long timestamp, MessageUser sender)根据指定的消息内容、时间戳和 MessageUser 向此类似对话的通知添加消息。
NotificationRequest.NotificationConversationalContentaddConversationalMessage(NotificationRequest.NotificationConversationalContent.ConversationalMessage message)将指定消息添加到此类似对话的通知中。
StringgetAdditionalText()获取已通过调用 setAdditionalText(java.lang.String) 为这个类似对话的通知设置的附加文本。
ListNotificationRequest.NotificationConversationalContent.ConversationalMessagegetAllConversationalMessages()获取包含在此类似对话的通知中的所有消息。
StringgetConversationTitle()获取要为对话显示的标题。
MessageUsergetMessageUser()获取用户在此类似对话的通知中发送的任何消息要显示的消息发件人。
StringgetText()获取该类会话通知调用 setText(java.lang.String) 设置的通知内容。
StringgetTitle()获取通过调用 setTitle(java.lang.String) 为这个类似对话的通知设置的标题。
booleanisConversationGroup()检查此通知是否代表群组对话。
booleanmarshalling(Parcel out)将此通知对话内容对象编组到包裹中。
NotificationRequest.NotificationConversationalContentsetAdditionalText(String additionalText)设置要包含在此类似对话的通知中的附加文本。
NotificationRequest.NotificationConversationalContentsetConversationGroup(boolean conversationGroup)设置此通知是否代表群组对话。
NotificationRequest.NotificationConversationalContentsetConversationTitle(String conversationTitle)设置要为对话显示的标题。
NotificationRequest.NotificationConversationalContentsetText(String text)设置要包含在此类似对话的通知中的文本。
NotificationRequest.NotificationConversationalContentsetTitle(String title)设置此对话式通知的标题。
StringtoString()返回对象的字符串表示形式。
booleanunmarshalling(Parcel in)从 Parcel 中解组此 NotificationConversationalContent 对象。
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
从接口 ohos.utils.Sequenceable 继承的方法
hasFileDescriptor

构造函数详细信息

NotificationConversationalContent

public NotificationConversationalContent(MessageUser user) throws IllegalArgumentException

用于创建具有指定 MessageUser 的 NotificationConversationalContent 实例的构造函数。

参数:

参数名称参数描述
user指示在此类似对话的通知中发送所有 Message 对象的 MessageUser。 此参数不能为空。

Throws:

Throw名称Throw描述
IllegalArgumentException如果 user 为 null,则引发此异常。

Since:

3

方法详情

getMessageUser

public MessageUser getMessageUser()

获取用户在此类似对话的通知中发送的任何消息要显示的消息发件人。

返回:

返回消息发送者。

Since:

3

getTitle

public String getTitle()

获取通过调用 setTitle(java.lang.String) 为这个类似对话的通知设置的标题。

如果 setConversationTitle(java.lang.String) 与 addConversationalMessage(ohos.event.notification.NotificationRequest.NotificationConversationalContent.ConversationalMessage) 或 addConversationalMessage(java.lang.String,long,ohos.event.notification.MessageUser) 一起调用此通知, 此方法的返回值将是 getConversationTitle() 的返回值和最后添加的 Message 的 MessageUser 上调用的 MessageUser#getName() 的返回值的组合。

返回:

返回此通知的标题。

Since:

3

setTitle

public NotificationRequest.NotificationConversationalContent setTitle(String title)

设置此对话式通知的标题。

参数:

参数名称参数描述
title指示此类似对话的通知的标题。

返回:

返回此 NotificationConversationalContent 对象。

Since:

3

getText

public String getText()

获取该类会话通知调用 setText(java.lang.String) 设置的通知内容。

如果还为此通知调用 addConversationalMessage(ohos.event.notification.NotificationRequest.NotificationConversationalContent.ConversationalMessage) 或 addConversationalMessage(java.lang.String,long,ohos.event.notification.MessageUser),则此方法的返回值将是 在最后添加的消息上调用的 ConversationalMessage#getText() 的返回值。

返回:

返回通知内容。

Since:

3

setText

public NotificationRequest.NotificationConversationalContent setText(String text)

设置要包含在此类似对话的通知中的文本。 如果此通知也调用了 setConversationTitle(java.lang.String),则此方法不生效。

参数:

参数名称参数描述
text指示要包含的文本。

返回:

返回此 NotificationConversationalContent 对象。

Since:

3

getAdditionalText

public String getAdditionalText()

获取已通过调用 setAdditionalText(java.lang.String) 为这个类似对话的通知设置的附加文本。

返回:

返回此通知的附加文本。

Since:

3

setAdditionalText

public NotificationRequest.NotificationConversationalContent setAdditionalText(String additionalText)

设置要包含在此类似对话的通知中的附加文本。

附加文本是对通过调用 setText(java.lang.String) 设置的通知文本的补充。 附加文本的字体小于通知文本,并在单独的行中显示。

参数:

参数名称参数描述
additionalText指示要包含的附加文本。

返回:

返回此 NotificationConversationalContent 对象。

Since:

3

getConversationTitle

public String getConversationTitle()

获取要为对话显示的标题。

返回:

返回要为对话显示的标题。

Since:

3

setConversationTitle

public NotificationRequest.NotificationConversationalContent setConversationTitle(String conversationTitle)

设置要为对话显示的标题。

此方法中设置的标题将通过调用 setTitle(java.lang.String) 覆盖一组。

参数:

参数名称参数描述
conversationTitle指示要为对话显示的标题。

返回:

返回此 NotificationConversationalContent 对象。

Since:

3

isConversationGroup

public boolean isConversationGroup()

检查此通知是否代表群组对话。

返回:

如果此通知表示群组对话,则返回 true; 否则返回 false。

Since:

3

setConversationGroup

public NotificationRequest.NotificationConversationalContent setConversationGroup(boolean conversationGroup)

设置此通知是否代表群组对话。

通过调用 NotificationRequest#setBigIcon(PixelMap) 为该通知设置的大图标(如果有)仅在此方法设置为 true 时才会显示。

参数:

参数名称参数描述
conversationGroup指定此通知是否代表组对话。 true 表示群聊,false 表示不是。

返回:

返回此 NotificationConversationalContent 对象。

Since:

3

getAllConversationalMessages

public ListNotificationRequest.NotificationConversationalContent.ConversationalMessage getAllConversationalMessages()

获取包含在此类似对话的通知中的所有消息。

返回:

返回包含的所有 Message 对象的列表。

Since:

3

addConversationalMessage

public NotificationRequest.NotificationConversationalContent addConversationalMessage(NotificationRequest.NotificationConversationalContent.ConversationalMessage message)

将指定消息添加到此类似对话的通知中。 所有消息将按添加顺序显示。

参数:

参数名称参数描述
message指示要添加的 ConversationalMessage 对象。

返回:

返回此 NotificationConversationalContent 对象。

Since:

3

addConversationalMessage

public NotificationRequest.NotificationConversationalContent addConversationalMessage(String text, long timestamp, MessageUser sender) throws IllegalArgumentException

根据指定的消息内容、时间戳和 MessageUser 向此类似对话的通知添加消息。 所有消息将按添加顺序显示。

参数:

参数名称参数描述
text指示要作为消息内容显示的文本。 此参数不能为空。
timestamp指示消息到达的时间。
sender指示发送消息的 MessageUser。

返回:

返回此 NotificationConversationalContent 对象。

Throws:

Throw名称Throw描述
IllegalArgumentException如果 text 为 null,则引发此异常。

Since:

3

marshalling

public boolean marshalling(Parcel out)

将此 NotificationConversationalContent 对象编组为 Parcel。

进程可以调用 unmarshalling(ohos.utils.Parcel) 方法从 Parcel 中解组此 NotificationConversationalContent 对象,以实现进程间通信 (IPC)。

指定者:

接口 Sequenceable 中的编组

参数:

参数名称参数描述
out指示用于编组的 Parcel 对象。

返回:

如果编组成功,则返回 true; 否则返回 false。

Since:

3

unmarshalling

public boolean unmarshalling(Parcel in)

从 Parcel 中解组此 NotificationConversationalContent 对象。

指定者:

在接口 Sequenceable 中解组

参数:

参数名称参数描述
in指示用于解组的 Parcel 对象。

返回:

如果解组成功,则返回 true; 否则返回 false。

Since:

3

toString

public String toString()

从类复制的描述:对象

返回对象的字符串表示形式。 通常,toString 方法返回一个“以文本方式表示”该对象的字符串。 结果应该是一个简洁但信息丰富的表示,易于人们阅读。 建议所有子类重写此方法。

Object 类的 toString 方法返回一个字符串,该字符串由对象作为其实例的类的名称、at 符号字符“@”和对象哈希码的无符号十六进制表示形式组成。 换句话说,此方法返回一个等于以下值的字符串:

 getClass().getName() + '@' + Integer.toHexString(hashCode()) 

覆盖:

类 Object 中的 toString

返回:

对象的字符串表示形式。

Since:

4

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/170285.html<

(0)
运维的头像运维
上一篇2025-03-22 08:03
下一篇 2025-03-22 08:04

相关推荐

  • 个人主题怎么制作?

    制作个人主题是一个将个人风格、兴趣或专业领域转化为视觉化或结构化内容的过程,无论是用于个人博客、作品集、社交媒体账号还是品牌形象,核心都是围绕“个人特色”展开,以下从定位、内容规划、视觉设计、技术实现四个维度,详细拆解制作个人主题的完整流程,明确主题定位:找到个人特色的核心主题定位是所有工作的起点,需要先回答……

    2025-11-20
    0
  • 社群营销管理关键是什么?

    社群营销的核心在于通过建立有温度、有价值、有归属感的社群,实现用户留存、转化和品牌传播,其管理需贯穿“目标定位-内容运营-用户互动-数据驱动-风险控制”全流程,以下从五个维度展开详细说明:明确社群定位与目标社群管理的首要任务是精准定位,需明确社群的核心价值(如行业交流、产品使用指导、兴趣分享等)、目标用户画像……

    2025-11-20
    0
  • 香港公司网站备案需要什么材料?

    香港公司进行网站备案是一个涉及多部门协调、流程相对严谨的过程,尤其需兼顾中国内地与香港两地的监管要求,由于香港公司注册地与中国内地不同,其网站若主要服务内地用户或使用内地服务器,需根据服务器位置、网站内容性质等,选择对应的备案路径(如工信部ICP备案或公安备案),以下从备案主体资格、流程步骤、材料准备、注意事项……

    2025-11-20
    0
  • 如何企业上云推广

    企业上云已成为数字化转型的核心战略,但推广过程中需结合行业特性、企业痛点与市场需求,构建系统性、多维度的推广体系,以下从市场定位、策略设计、执行落地及效果优化四个维度,详细拆解企业上云推广的实践路径,精准定位:明确目标企业与核心价值企业上云并非“一刀切”的方案,需先锁定目标客户群体,提炼差异化价值主张,客户分层……

    2025-11-20
    0
  • PS设计搜索框的实用技巧有哪些?

    在PS中设计一个美观且功能性的搜索框需要结合创意构思、视觉设计和用户体验考量,以下从设计思路、制作步骤、细节优化及交互预览等方面详细说明,帮助打造符合需求的搜索框,设计前的规划明确使用场景:根据网站或APP的整体风格确定搜索框的调性,例如极简风适合细线条和纯色,科技感适合渐变和发光效果,电商类则可能需要突出搜索……

    2025-11-20
    0

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注