hyphenate_SDK4.0 4.5.0
hyphenate java IM SDK
| Public 成员函数 | 静态 Public 成员函数 | 所有成员列表
com.hyphenate.chat.EMMessage类 参考

继承自 com.hyphenate.chat.EMBase< T >, Parcelable , 以及 Cloneable .

enum  ChatType
 
enum  Direct
 
enum  Status
 
enum  Type
 

Public 成员函数

Status status ()
 
void setStatus (Status status)
 
Type getType ()
 
EMMessageBody getBody ()
 
long getMsgTime ()
 
void setMsgTime (long msgTime)
 
long localTime ()
 
void setLocalTime (long serverTime)
 
boolean isNeedGroupAck ()
 
void setIsNeedGroupAck (boolean need)
 
int groupAckCount ()
 
void setGroupAckCount (int count)
 
void setIsChatThreadMessage (boolean isChatThreadMessage)
 
boolean isChatThreadMessage ()
 
EMChatThread getChatThread ()
 
void setBody (EMMessageBody body)
 
void addBody (EMMessageBody body)
 
String getFrom ()
 
void setFrom (String from)
 
String getRecaller ()
 
void setTo (String to)
 
String getTo ()
 
String getMsgId ()
 
void setMsgId (String msgId)
 
synchronized void setMessageStatusCallback (EMCallBack callback)
 
void setAttribute (String attribute, boolean value)
 
void setAttribute (String attribute, int value)
 
void setAttribute (String attribute, long value)
 
void setAttribute (String attribute, float value)
 
void setAttribute (String attribute, double value)
 
void setAttribute (String attribute, JSONObject value)
 
void setAttribute (String attribute, JSONArray value)
 
void setAttribute (String attribute, String value)
 
boolean getBooleanAttribute (String attribute) throws HyphenateException
 
boolean getBooleanAttribute (String attribute, boolean defaultValue)
 
int getIntAttribute (String attribute, int defaultValue)
 
long getLongAttribute (String attribute, long defaultValue)
 
float getFloatAttribute (String attribute, float defaultValue)
 
double getDoubleAttribute (String attribute, double defaultValue)
 
int getIntAttribute (String attribute) throws HyphenateException
 
long getLongAttribute (String attribute) throws HyphenateException
 
float getFloatAttribute (String attribute) throws HyphenateException
 
double getDoubleAttribute (String attribute) throws HyphenateException
 
String getStringAttribute (String attribute) throws HyphenateException
 
String getStringAttribute (String attribute, String defaultValue)
 
JSONObject getJSONObjectAttribute (String attribute) throws HyphenateException
 
JSONArray getJSONArrayAttribute (String attribute) throws HyphenateException
 
ChatType getChatType ()
 
void setChatType (ChatType chatType)
 
boolean isAcked ()
 
void setAcked (boolean isAcked)
 
boolean isDelivered ()
 
void setDelivered (boolean isDelivered)
 
boolean isUnread ()
 
void setUnread (boolean unread)
 
boolean isListened ()
 
void setListened (boolean isListened)
 
String getUserName ()
 
void setDeliverAcked (boolean isDeliverAcked)
 
int progress ()
 
void setProgress (int progress)
 
Direct direct ()
 
void setDirection (Direct dir)
 
String conversationId ()
 
Map< String, Object > ext ()
 
Map< String, Object > getAttributes ()
 
List< EMMessageReactiongetMessageReaction ()
 
boolean isOnlineState ()
 
void setPriority (EMChatRoomMessagePriority priority)
 
boolean isDeliverOnlineOnly ()
 
void deliverOnlineOnly (boolean onlineOnly)
 
void setReceiverList (List< String > receiverList)
 
List< String > receiverList ()
 
boolean isBroadcast ()
 
boolean isContentReplaced ()
 
EMMessagePinInfo pinnedInfo ()
 

静态 Public 成员函数

static EMMessage createSendMessage (Type type)
 
static EMMessage createReceiveMessage (Type type)
 
static EMMessage createTxtSendMessage (String content, String username)
 
static EMMessage createTextSendMessage (String content, String username)
 
static EMMessage createVoiceSendMessage (String filePath, int timeLength, String username)
 
static EMMessage createVoiceSendMessage (Uri filePath, int timeLength, String username)
 
static EMMessage createImageSendMessage (String filePath, boolean sendOriginalImage, String username)
 
static EMMessage createImageSendMessage (Uri imgUri, boolean sendOriginalImage, String username)
 
static EMMessage createVideoSendMessage (String videofilePath, String imageThumbPath, int timeLength, String username)
 
static EMMessage createVideoSendMessage (Uri videofilePath, String imageThumbPath, int timeLength, String username)
 
static EMMessage createVideoSendMessage (Uri videofilePath, Uri imageThumbPath, int timeLength, String username)
 
static EMMessage createLocationSendMessage (double latitude, double longitude, String locationAddress, String buildingName, String username)
 
static EMMessage createLocationSendMessage (double latitude, double longitude, String locationAddress, String username)
 
static EMMessage createFileSendMessage (String filePath, String username)
 
static EMMessage createFileSendMessage (Uri filePath, String username)
 
static EMMessage createCombinedSendMessage (String title, String summary, String compatibleText, List< String > messageIdList, String userId)
 

详细描述

消息对象,表示一条发送或接收到的消息。

例如: 构造一条文本发送消息:

EMMessage msg = EMMessage.createSendMessage(EMMessage.Type.TXT);
msg.setTo("user1");
TextMessageBody body = new TextMessageBody("hello from hyphenate sdk");
msg.addBody(body);

构造一条图片消息:

EMMessage msg = EMMessage.createSendMessage(EMMessage.Type.IMAGE);
msg.setTo("user1");
ImageMessageBody body = new ImageMessageBody(imageFileUrl);
msg.addBody(body);

成员函数说明

◆ addBody()

void com.hyphenate.chat.EMMessage.addBody ( EMMessageBody  body)

添加消息体。

本方法与设置消息体 EMMessage#setBody(EMMessageBody) 的方法效果相同。推荐使用后者。

只支持一条消息添加一个消息体。

参数
body消息体。

◆ conversationId()

String com.hyphenate.chat.EMMessage.conversationId ( )

获取会话 ID。

返回
会话 ID。

◆ createCombinedSendMessage()

static EMMessage com.hyphenate.chat.EMMessage.createCombinedSendMessage ( String  title,
String  summary,
String  compatibleText,
List< String >  messageIdList,
String  userId 
)
static

创建一个合并转发消息的发送消息。

对于不支持合并转发消息的 SDK 版本,该类消息会被解析为文本 Type#TXT 消息,消息内容为 compatibleText 携带的内容,其他字段会被忽略。

参数
title合并消息的标题。该字段可以设置为 null 或者空字符串。
summary合并消息的概要。该字段可以设置为 null 或者空字符串。
compatibleText合并消息的兼容信息。该字段可以设置为 null 或者空字符串。该字段用于需要兼容不支持合并转发消息的版本。
messageIdList合并消息的消息 ID 列表。列表不可为null或者空,最多可包含 300 个消息 ID。调用 EMChatManager#sendMessage(EMMessage) 方法发送消息会检查该字段的设置。
userId消息接收方。该字段的设置取决于会话类型:
  • 单聊:对方用户 ID。
  • 群聊:群组 ID。
  • 子区会话:子区 ID。
  • 聊天室聊天:聊天室 ID。
返回
合并转发消息对象。

◆ createFileSendMessage() [1/2]

static EMMessage com.hyphenate.chat.EMMessage.createFileSendMessage ( String  filePath,
String  username 
)
static

创建一个普通文件发送消息。

参数
filePath文件路径。
username消息接收方的设置取决于会话类型:
  • 单聊:对方用户 ID。
  • 群聊:群组 ID。
  • 子区会话:子区 ID。
  • 聊天室聊天:聊天室 ID。
返回
消息对象。

◆ createFileSendMessage() [2/2]

static EMMessage com.hyphenate.chat.EMMessage.createFileSendMessage ( Uri  filePath,
String  username 
)
static

创建一个普通文件发送消息。

参数
filePath文件路径。
username消息接收方的设置取决于会话类型:
  • 单聊:对方用户 ID。
  • 群聊:群组 ID。
  • 子区会话:子区 ID。
  • 聊天室聊天:聊天室 ID。
返回
消息对象。

◆ createImageSendMessage() [1/2]

static EMMessage com.hyphenate.chat.EMMessage.createImageSendMessage ( String  filePath,
boolean  sendOriginalImage,
String  username 
)
static

创建一个图片发送消息。

参数
filePath图片路径。
sendOriginalImage是否发送原图:
  • true:发送原图。
  • false:若图片小于 100 KB,发送原图;若图片大于等于 100 KB, 发送压缩后的图片。
username消息接收方的设置取决于会话类型:
  • 单聊:对方用户 ID。
  • 群聊:群组 ID。
  • 子区会话:子区 ID。
  • 聊天室聊天:聊天室 ID。
返回
消息对象。

◆ createImageSendMessage() [2/2]

static EMMessage com.hyphenate.chat.EMMessage.createImageSendMessage ( Uri  imgUri,
boolean  sendOriginalImage,
String  username 
)
static

创建一个图片发送消息。

参数
imgUri图片 URI。
sendOriginalImage是否发送原图:
  • true:发送原图。
  • false:若图片小于 100 KB,发送原图;若图片大于等于 100 KB, 发送压缩后的图片。
username消息接收方的设置取决于会话类型:
  • 单聊:对方用户 ID。
  • 群聊:群组 ID。
  • 子区会话:子区 ID。
  • 聊天室聊天:聊天室 ID。
返回
消息对象。

◆ createLocationSendMessage() [1/2]

static EMMessage com.hyphenate.chat.EMMessage.createLocationSendMessage ( double  latitude,
double  longitude,
String  locationAddress,
String  buildingName,
String  username 
)
static

创建一个位置发送消息。

参数
latitude纬度。
longitude经度。
locationAddress位置详情。
buildingName建筑物名称。
username消息接收方的设置取决于会话类型:
  • 单聊:对方用户 ID。
  • 群聊:群组 ID。
  • 子区会话:子区 ID。
  • 聊天室聊天:聊天室 ID。
返回
消息对象。

◆ createLocationSendMessage() [2/2]

static EMMessage com.hyphenate.chat.EMMessage.createLocationSendMessage ( double  latitude,
double  longitude,
String  locationAddress,
String  username 
)
static

创建一个位置发送消息。

参数
latitude纬度。
longitude经度。
locationAddress位置详情。
username消息接收方的设置取决于会话类型:
  • 单聊:对方用户 ID。
  • 群聊:群组 ID。
  • 子区会话:子区 ID。
  • 聊天室聊天:聊天室 ID。
返回
消息对象。

◆ createReceiveMessage()

static EMMessage com.hyphenate.chat.EMMessage.createReceiveMessage ( Type  type)
static

创建一个接收消息。

参数
type消息类型。
返回
消息对象。

◆ createSendMessage()

static EMMessage com.hyphenate.chat.EMMessage.createSendMessage ( Type  type)
static

创建一个发送消息。

参数
type消息类型。
返回
消息对象。

◆ createTextSendMessage()

static EMMessage com.hyphenate.chat.EMMessage.createTextSendMessage ( String  content,
String  username 
)
static

创建一个文本发送消息。

参数
content文本内容。
username消息接收方的设置取决于会话类型:
  • 单聊:对方用户 ID。
  • 群聊:群组 ID。
  • 子区会话:子区 ID。
  • 聊天室聊天:聊天室 ID。
返回
消息对象。

◆ createTxtSendMessage()

static EMMessage com.hyphenate.chat.EMMessage.createTxtSendMessage ( String  content,
String  username 
)
static

创建一个文本发送消息。

参数
content文本内容。
username消息接收方的设置取决于会话类型:
  • 单聊:对方用户 ID。
  • 群聊:群组 ID。
  • 子区会话:子区 ID。
  • 聊天室聊天:聊天室 ID。
返回
消息对象。
弃用:
已废弃。请用 createTextSendMessage(String, String) 代替。

◆ createVideoSendMessage() [1/3]

static EMMessage com.hyphenate.chat.EMMessage.createVideoSendMessage ( String  videofilePath,
String  imageThumbPath,
int  timeLength,
String  username 
)
static

创建一个视频发送消息。

参数
videofilePath视频文件路径。
imageThumbPath视频第一帧图缩略图。
timeLength视频时间长度,单位为秒。
username消息接收方的设置取决于会话类型:
  • 单聊:对方用户 ID。
  • 群聊:群组 ID。
  • 子区会话:子区 ID。
  • 聊天室聊天:聊天室 ID。
返回
消息对象。

◆ createVideoSendMessage() [2/3]

static EMMessage com.hyphenate.chat.EMMessage.createVideoSendMessage ( Uri  videofilePath,
String  imageThumbPath,
int  timeLength,
String  username 
)
static

创建一个视频发送消息。

参数
videofilePath视频文件路径。
imageThumbPath视频第一帧图缩略图。
timeLength视频时间长度,单位为秒。
username消息接收方的设置取决于会话类型:
  • 单聊:对方用户 ID。
  • 群聊:群组 ID。
  • 子区会话:子区 ID。
  • 聊天室聊天:聊天室 ID。
返回
消息对象。

◆ createVideoSendMessage() [3/3]

static EMMessage com.hyphenate.chat.EMMessage.createVideoSendMessage ( Uri  videofilePath,
Uri  imageThumbPath,
int  timeLength,
String  username 
)
static

创建一个视频发送消息。

参数
videofilePath视频文件路径。
imageThumbPath视频第一帧图缩略图。
timeLength视频时间长度,单位为秒。
username消息接收方的设置取决于会话类型:
  • 单聊:对方用户 ID。
  • 群聊:群组 ID。
  • 子区会话:子区 ID。
  • 聊天室聊天:聊天室 ID。
返回
消息对象。

◆ createVoiceSendMessage() [1/2]

static EMMessage com.hyphenate.chat.EMMessage.createVoiceSendMessage ( String  filePath,
int  timeLength,
String  username 
)
static

创建一个语音发送消息。

参数
filePath语音文件路径。
timeLength语音时间长度,单位为秒。
username消息接收方的设置取决于会话类型:
  • 单聊:对方用户 ID。
  • 群聊:群组 ID。
  • 子区会话:子区 ID。
  • 聊天室聊天:聊天室 ID。
返回
消息对象。

◆ createVoiceSendMessage() [2/2]

static EMMessage com.hyphenate.chat.EMMessage.createVoiceSendMessage ( Uri  filePath,
int  timeLength,
String  username 
)
static

创建一个语音发送消息。

参数
filePath语音文件 URI。
timeLength语音时间长度,单位为秒。
username消息接收方的设置取决于会话类型:
  • 单聊:对方用户 ID。
  • 群聊:群组 ID。
  • 子区会话:子区 ID。
  • 聊天室聊天:聊天室 ID。
返回
消息对象。

◆ deliverOnlineOnly()

void com.hyphenate.chat.EMMessage.deliverOnlineOnly ( boolean  onlineOnly)

设置消息是否只投递给在线用户。

参数
onlineOnly消息是否只投递给在线用户:
  • true:只有消息接收方在线时才能投递成功。若接收方离线,则消息会被丢弃。
  • false(默认):如果用户在线,则直接投递;如果用户离线,消息会在用户上线时投递。

◆ direct()

Direct com.hyphenate.chat.EMMessage.direct ( )

消息方向。

  • SEND:该消息是当前用户发送出去的。
  • RECEIVE:该消息是当前用户接收到的。
返回
发送或接收,详见 Direct

◆ ext()

Map< String, Object > com.hyphenate.chat.EMMessage.ext ( )

获取消息包含的全部扩展字段。

返回
消息的全部扩展字段,以 Map<String, Object> 形式返回。返回 Entry.value 的具体类型有 Boolean, Integer, Long, Float, Double, String。 输入 JsonObject 的属性,map 结构返回时属性是 String。

◆ getAttributes()

Map< String, Object > com.hyphenate.chat.EMMessage.getAttributes ( )

获取消息包含的全部扩展字段。

返回
消息的全部扩展字段,以 Map<String, Object> 形式返回,其中 Entry.value 可为 Boolean、Integer、Long、Float、Double、String、JsonObject、或 JsonArray 类型。

◆ getBody()

EMMessageBody com.hyphenate.chat.EMMessage.getBody ( )

获取消息体。

返回
消息体。

◆ getBooleanAttribute() [1/2]

boolean com.hyphenate.chat.EMMessage.getBooleanAttribute ( String  attribute) throws HyphenateException

获取 Bool 类型的消息扩展属性。

参数
attribute属性名。
返回
属性值。
异常
HyphenateException如果有异常会在这里抛出,包含错误码和异常原因。详见 EMError

◆ getBooleanAttribute() [2/2]

boolean com.hyphenate.chat.EMMessage.getBooleanAttribute ( String  attribute,
boolean  defaultValue 
)

获取 Bool 类型的消息扩展属性。

参数
attribute属性名。
defaultValue属性的默认值。
返回
属性值。

◆ getChatThread()

EMChatThread com.hyphenate.chat.EMMessage.getChatThread ( )

获取子区概览信息。

子区概览信息仅在创建子区后携带。

返回
子区概览信息。

◆ getChatType()

ChatType com.hyphenate.chat.EMMessage.getChatType ( )

获取聊天类型。

返回
聊天类型。

◆ getDoubleAttribute() [1/2]

double com.hyphenate.chat.EMMessage.getDoubleAttribute ( String  attribute) throws HyphenateException

获取消息的 Double 类型扩展属性。

参数
attribute属性名。
返回
属性值。
异常
HyphenateException如果有异常会在这里抛出,包含错误码和异常原因。详见 EMError

◆ getDoubleAttribute() [2/2]

double com.hyphenate.chat.EMMessage.getDoubleAttribute ( String  attribute,
double  defaultValue 
)

获取消息的 Double 类型扩展属性。

参数
attribute属性名。
defaultValue属性的默认值。
返回
属性值。

◆ getFloatAttribute() [1/2]

float com.hyphenate.chat.EMMessage.getFloatAttribute ( String  attribute) throws HyphenateException

获取消息的 Float 类型扩展属性。

参数
attribute属性名。
返回
属性值。
异常
HyphenateException如果有异常会在这里抛出,包含错误码和异常原因。详见 EMError

◆ getFloatAttribute() [2/2]

float com.hyphenate.chat.EMMessage.getFloatAttribute ( String  attribute,
float  defaultValue 
)

获取消息的 Float 类型扩展属性。

参数
attribute属性名。
defaultValue属性的默认值。
返回
属性值。

◆ getFrom()

String com.hyphenate.chat.EMMessage.getFrom ( )

获取消息发送方的用户 ID。

返回
用户 ID。

◆ getIntAttribute() [1/2]

int com.hyphenate.chat.EMMessage.getIntAttribute ( String  attribute) throws HyphenateException

获取消息的 Int 类型扩展属性。

参数
attribute属性名。
返回
属性值。
异常
HyphenateException如果有异常会在这里抛出,包含错误码和异常原因。详见 EMError

◆ getIntAttribute() [2/2]

int com.hyphenate.chat.EMMessage.getIntAttribute ( String  attribute,
int  defaultValue 
)

获取消息的 Int 类型扩展属性。

参数
attribute属性名。
defaultValue默认值。
返回
属性值。

◆ getJSONArrayAttribute()

JSONArray com.hyphenate.chat.EMMessage.getJSONArrayAttribute ( String  attribute) throws HyphenateException

获取消息的 JSONArray 类型扩展属性。

参数
attribute属性名。
返回
属性值。
异常
HyphenateException如果有异常会在这里抛出,包含错误码和异常原因。详见 EMError

◆ getJSONObjectAttribute()

JSONObject com.hyphenate.chat.EMMessage.getJSONObjectAttribute ( String  attribute) throws HyphenateException

获取消息的 JSONObject 类型扩展属性。

参数
attribute属性名。
返回
属性值。
异常
HyphenateException如果有异常会在这里抛出,包含错误码和异常原因。详见 EMError

◆ getLongAttribute() [1/2]

long com.hyphenate.chat.EMMessage.getLongAttribute ( String  attribute) throws HyphenateException

获取消息的 Long 类型扩展属性。

参数
attribute属性名。
返回
属性值。
异常
HyphenateException如果有异常会在这里抛出,包含错误码和异常原因。详见 EMError

◆ getLongAttribute() [2/2]

long com.hyphenate.chat.EMMessage.getLongAttribute ( String  attribute,
long  defaultValue 
)

获取消息的 Long 类型扩展属性。

参数
attribute属性名。
defaultValue属性的默认值。
返回
属性值。

◆ getMessageReaction()

List< EMMessageReaction > com.hyphenate.chat.EMMessage.getMessageReaction ( )

获取 Reaction 列表。

返回
Reaction 列表。

◆ getMsgId()

String com.hyphenate.chat.EMMessage.getMsgId ( )

获取消息的 ID。

返回
消息 ID。

◆ getMsgTime()

long com.hyphenate.chat.EMMessage.getMsgTime ( )

获取消息的服务器时间戳。

该时间戳为服务器接收消息的时间。

返回
服务器接收消息的时间戳。

◆ getRecaller()

String com.hyphenate.chat.EMMessage.getRecaller ( )

获取消息撤回者的用户 ID。

返回
撤回者用户 ID。

◆ getStringAttribute() [1/2]

String com.hyphenate.chat.EMMessage.getStringAttribute ( String  attribute) throws HyphenateException

获取消息的 String 类型扩展属性。

参数
attribute属性名。
返回
属性值。
异常
HyphenateException如果有异常会在这里抛出,包含错误码和异常原因。详见 EMError

◆ getStringAttribute() [2/2]

String com.hyphenate.chat.EMMessage.getStringAttribute ( String  attribute,
String  defaultValue 
)

获取消息的 String 类型扩展属性。

参数
attribute属性名。
defaultValue默认值。
返回
属性值。

◆ getTo()

String com.hyphenate.chat.EMMessage.getTo ( )

获取消息接收者的用户名。

返回
接收者的用户名。

◆ getType()

Type com.hyphenate.chat.EMMessage.getType ( )

获取消息类型。

返回
消息类型。

◆ getUserName()

String com.hyphenate.chat.EMMessage.getUserName ( )

获取对端用户的 ID:

  • 单聊:对端用户的 ID;
  • 群聊:群组 ID;
  • 子区会话:子区 ID;
  • 聊天室:聊天室 ID。
返回
对端用户的 ID。

◆ groupAckCount()

int com.hyphenate.chat.EMMessage.groupAckCount ( )

群消息已读人数。

返回
消息已读人数。

◆ isAcked()

boolean com.hyphenate.chat.EMMessage.isAcked ( )

获取对方是否已读。

返回
消息是否已读: -true:已读。 -false:未读。

◆ isBroadcast()

boolean com.hyphenate.chat.EMMessage.isBroadcast ( )

是否是全局广播消息。

返回
是否是全局广播消息。

◆ isChatThreadMessage()

boolean com.hyphenate.chat.EMMessage.isChatThreadMessage ( )

获取消息是否是子区消息。

返回
返回是否是子区消息的结果。
  • true表示是子区消息;
  • false表示不是子区消息。

◆ isContentReplaced()

boolean com.hyphenate.chat.EMMessage.isContentReplaced ( )

消息内容是否被替换过。

返回
消息内容是否被替换过。

◆ isDelivered()

boolean com.hyphenate.chat.EMMessage.isDelivered ( )

获取消息是否成功送达。

返回
消息是否成功送达。
  • true:已送达。
  • false:未送达。

◆ isDeliverOnlineOnly()

boolean com.hyphenate.chat.EMMessage.isDeliverOnlineOnly ( )

判断消息是否只投递在线用户。

返回
- true:只投递在线用户。
  • false:投递所有用户。

◆ isListened()

boolean com.hyphenate.chat.EMMessage.isListened ( )

获取语音消息是否已听。

返回
语音是否已听:
  • true:已听;
  • false:未听。

◆ isNeedGroupAck()

boolean com.hyphenate.chat.EMMessage.isNeedGroupAck ( )

消息是否需要群组已读回执。

返回
消息是否需要群组已读回执
  • true:需要已读回执;
  • false:不需要已读回执。

◆ isOnlineState()

boolean com.hyphenate.chat.EMMessage.isOnlineState ( )

是否为在线消息。

注解
该字段标记服务器下发消息时判断用户是在线还是离线的状态。

该字段为服务器下发字段,不在本地数据库中存储。对于从数据库读取的消息或拉取的漫游消息,该字段的值默认为 true

返回
是否为在线消息。
  • (默认)true:是。
  • false:否。

◆ isUnread()

boolean com.hyphenate.chat.EMMessage.isUnread ( )

检查消息是否未读。

返回
消息是否未读。
  • true: 未读;
  • false: 已读。

◆ localTime()

long com.hyphenate.chat.EMMessage.localTime ( )

获取消息的本地时间戳。

该时间戳为消息的本地创建时间戳。

返回
消息的本地时间戳。

◆ pinnedInfo()

EMMessagePinInfo com.hyphenate.chat.EMMessage.pinnedInfo ( )

获取消息的置顶详情。

返回
消息的置顶详情。

◆ progress()

int com.hyphenate.chat.EMMessage.progress ( )

消息中的附件的上传或者下载进度。

消息附件的缩略图不涉及进度信息。

返回
消息中的附件的上传或者下载进度,取值范围为 [0,100]。

◆ receiverList()

List< String > com.hyphenate.chat.EMMessage.receiverList ( )

定向消息的接收方。

返回
定向消息的接收方。

◆ setAcked()

void com.hyphenate.chat.EMMessage.setAcked ( boolean  isAcked)

设置对方是否已读。

该方法由 SDK 调用,而非开发者。

参数
isAcked消息是否已读: -true:已读。 -false:未读。

◆ setAttribute() [1/8]

void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
boolean  value 
)

设置消息的 Bool 类型的扩展属性。

参数
attribute属性名。
value属性值。

◆ setAttribute() [2/8]

void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
double  value 
)

设置消息的 Double 类型扩展属性。

参数
attribute属性名。
value属性值。

◆ setAttribute() [3/8]

void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
float  value 
)

设置消息的 Float 类型扩展属性。

参数
attribute属性名。
value属性值。

◆ setAttribute() [4/8]

void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
int  value 
)

设置消息的 Int 类型扩展属性。

参数
attribute属性名。
value属性值。

◆ setAttribute() [5/8]

void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
JSONArray  value 
)

设置消息的 JSONArray 类型扩展属性。

参数
attribute属性名。
value属性值。

◆ setAttribute() [6/8]

void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
JSONObject  value 
)

设置消息的 JSONObject 类型扩展属性。

参数
attribute属性名。
value属性值。

◆ setAttribute() [7/8]

void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
long  value 
)

设置消息的 Long 类型扩展属性。

参数
attribute属性名。
value属性值。

◆ setAttribute() [8/8]

void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
String  value 
)

设置消息的 String 类型扩展属性。

参数
attribute属性名。
value属性值。

◆ setBody()

void com.hyphenate.chat.EMMessage.setBody ( EMMessageBody  body)

(建议方法)设置消息体。

参数
body消息体。

◆ setChatType()

void com.hyphenate.chat.EMMessage.setChatType ( ChatType  chatType)

设置聊天类型。

参数
chatType聊天类型,默认为单聊。详见 ChatType

◆ setDeliverAcked()

void com.hyphenate.chat.EMMessage.setDeliverAcked ( boolean  isDeliverAcked)

设置消息已送达标记。

开发者不要调用,由 SDK 内部调用。

参数
isDeliverAcked
  • true:消息已送达。
  • false:消息未送达。

◆ setDelivered()

void com.hyphenate.chat.EMMessage.setDelivered ( boolean  isDelivered)

设置消息是否成功送达。

该方法由 SDK 调用,而非开发者。

参数
isDelivered消息是否成功送达。
  • true:已送达。
  • false:未送达。

◆ setDirection()

void com.hyphenate.chat.EMMessage.setDirection ( Direct  dir)

设置消息方向。

参数
dir消息的方向,详见 Direct

◆ setFrom()

void com.hyphenate.chat.EMMessage.setFrom ( String  from)

设置消息发送方的用户 ID。

参数
from发送方的用户 ID。

◆ setGroupAckCount()

void com.hyphenate.chat.EMMessage.setGroupAckCount ( int  count)

设置群消息已读人数。

参数
count群消息已读人数。

◆ setIsChatThreadMessage()

void com.hyphenate.chat.EMMessage.setIsChatThreadMessage ( boolean  isChatThreadMessage)

设置消息是否是子区消息。

参数
isChatThreadMessage- true表示设置成子区消息;
  • false表示不设置为子区消息。

◆ setIsNeedGroupAck()

void com.hyphenate.chat.EMMessage.setIsNeedGroupAck ( boolean  need)

设置群组消息是否需要已读回执。

参数
need群组消息是否需要已读回执:
  • true:需要;
  • false:不需要。

◆ setListened()

void com.hyphenate.chat.EMMessage.setListened ( boolean  isListened)

设置语音消息是否已听。

该方法由 SDK 调用,而非开发者。

参数
isListened语音消息是否已听:
  • true:已听。
  • false:未听。

◆ setLocalTime()

void com.hyphenate.chat.EMMessage.setLocalTime ( long  serverTime)

设置消息的本地时间戳。

该时间戳为消息的本地创建时间戳。

参数
serverTime消息的本地时间戳。

◆ setMessageStatusCallback()

synchronized void com.hyphenate.chat.EMMessage.setMessageStatusCallback ( EMCallBack  callback)

设置消息状态变化的回调。

设置消息状态回调,以便刷新界面。

参数
callback消息状态改变的回调。

◆ setMsgId()

void com.hyphenate.chat.EMMessage.setMsgId ( String  msgId)

设置本地消息 ID。

参数
msgId消息 ID。

◆ setMsgTime()

void com.hyphenate.chat.EMMessage.setMsgTime ( long  msgTime)

设置消息的服务器时间戳。

该时间戳为服务器接收消息的时间。

参数
msgTime服务器接收消息的时间戳。

◆ setPriority()

void com.hyphenate.chat.EMMessage.setPriority ( EMChatRoomMessagePriority  priority)

设置消息优先级 chatroom message priority

参数
priority

◆ setProgress()

void com.hyphenate.chat.EMMessage.setProgress ( int  progress)

设置消息中的附件的上传或者下载进度。

对于 app 开发者来说,通常不需要主动设置进度。详见 EMMessage#progress()

参数
progress消息中的附件的上传或者下载进度,取值范围为 [0,100]。

◆ setReceiverList()

void com.hyphenate.chat.EMMessage.setReceiverList ( List< String >  receiverList)

设置定向消息接收方。

该方法适用于群组和聊天室。若创建消息后不调用该方法,则消息发送给群组或聊天室的所有成员。

参数
receiverList定向消息接收方。若传入 null,则消息发送给群组或聊天室的所有成员。

◆ setStatus()

void com.hyphenate.chat.EMMessage.setStatus ( Status  status)

设置消息发送或接收的状态。

参数
status消息的状态。

◆ setTo()

void com.hyphenate.chat.EMMessage.setTo ( String  to)

设置消息的接收方的用户 ID。

参数
to消息接收方的用户 ID。

◆ setUnread()

void com.hyphenate.chat.EMMessage.setUnread ( boolean  unread)

设置消息是否未读。

建议在会话中,使用 EMConversation#markAllMessagesAsRead()

参数
unread消息是否未读:
  • true:设置消息为未读;
  • false:设置消息为已读。

◆ status()

Status com.hyphenate.chat.EMMessage.status ( )

获取消息的发送/接收状态。

返回
消息的发送/接收状态。

该类的文档由以下文件生成: