hyphenate_SDK4.0 4.8.0
hyphenate java IM SDK
|
Inherits com.hyphenate.chat.EMBase< T >, Parcelable, and Cloneable.
Classes | |
enum | ChatType |
enum | Direct |
enum | Status |
enum | Type |
Public Member Functions | |
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< EMMessageReaction > | getMessageReaction () |
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 () |
Static Public Member Functions | |
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) |
The message instance, which indicates a sent or received message.
For example: Constructs a text message to send:
Constructs an image message to send:
void com.hyphenate.chat.EMMessage.addBody | ( | EMMessageBody | body | ) |
Adds a message body.
This method is equivalent to EMMessage#setBody(EMMessageBody) which sets the message body. The latter is recommended.
Only one message body can be added for one message.
body | The message body. |
String com.hyphenate.chat.EMMessage.conversationId | ( | ) |
Gets the conversation ID.
|
static |
Creates a combined message for sending.
The SDKs that do not support combined messages will parse this type of message as a text message Type#TXT by resolving the value of compatibleText
into the content of the text message and igoring other fields. and the content of the message will be from compatibleText
, and other fields will be ignored.
title | The title of the combined message. It can be null or an empty string (""). |
summary | The summary of the combined message. It can be null or an empty string (""). |
compatibleText | The compatible text of the combined message. It can be null or an empty string (""). |
messageIdList | The list cannot be null or empty. It can contain a maximum of 300 message IDs. When you call EMChatManager#sendMessage(EMMessage) to send a message, the SDK will check the setting of this field. |
userId | The message recipient. The field setting is determined by the conversation type:
|
|
static |
Creates a file message for sending.
filePath | The file path. |
username | The message sender is determined by the conversation type:
|
|
static |
Creates a file message for sending.
filePath | The file path. |
username | The message sender is determined by the conversation type:
|
|
static |
Creates an image message for sending.
filePath | The image path. |
sendOriginalImage | Whether to send the original image.
|
username | The message sender is determined by the conversation type:
|
|
static |
Creates an image message for sending.
imgUri | The URI of the image. |
sendOriginalImage | Whether to send the original image.
|
username | The message sender is determined by the conversation type:
|
|
static |
Creates a location message for sending.
latitude | The latitude. |
longitude | The longitude. |
locationAddress | The location details. |
buildingName | The name of the building. |
username | The message sender is determined by the conversation type:
|
|
static |
Creates a location message for sending.
latitude | The latitude. |
longitude | The longitude. |
locationAddress | The location details. |
username | The message sender is determined by the conversation type:
|
Creates a received message instance.
type | The message type. |
Creates a message instance for sending.
type | The message type. |
|
static |
Creates a text message for sending.
content | The text content. |
username | The message sender is determined by the conversation type:
|
|
static |
Creates a text message for sending.
content | The text content. |
username | The message sender is determined by the conversation type:
|
|
static |
Creates a video message for sending.
videofilePath | The path of the video file. |
imageThumbPath | The path of thumbnail of the first frame of the video. |
timeLength | The video duration in seconds. |
username | The message sender is determined by the conversation type:
|
|
static |
Creates a video message for sending.
videofilePath | The path of the video file. |
imageThumbPath | The path of the thumbnail of the first frame of the video. |
timeLength | The video duration in seconds. |
username | The message sender is determined by the conversation type:
|
|
static |
Creates a video message for sending.
videofilePath | The path of the video file. |
imageThumbPath | The path of the thumbnail of the first frame of the video. |
timeLength | The video duration in seconds. |
username | The message sender is determined by the conversation type:
|
|
static |
Creates a voice message for sending.
filePath | The path of the voice file. |
timeLength | The voice duration in seconds. |
username | The message sender is determined by the conversation type:
|
|
static |
Creates a voice message for sending.
filePath | The URI of the voice file. |
timeLength | The voice duration in seconds. |
username | The user ID of the message recipient or group ID. |
void com.hyphenate.chat.EMMessage.deliverOnlineOnly | ( | boolean | onlineOnly | ) |
Sets whether the message is delivered only when the recipient(s) is/are online.
onlineOnly | Whether the message is delivered only when the recipient(s) is/are online:
|
Direct com.hyphenate.chat.EMMessage.direct | ( | ) |
The message direction.
Map< String, Object > com.hyphenate.chat.EMMessage.ext | ( | ) |
Gets all message extension fields. The return type is Map<String, Object>.
Map< String, Object > com.hyphenate.chat.EMMessage.getAttributes | ( | ) |
Gets all extension fields of the message.
EMMessageBody com.hyphenate.chat.EMMessage.getBody | ( | ) |
Gets the message body.
boolean com.hyphenate.chat.EMMessage.getBooleanAttribute | ( | String | attribute | ) | throws HyphenateException |
Gets a message extension attribute of the Boolean type.
attribute | The attribute name. |
HyphenateException | A description of the exception. See EMError. |
boolean com.hyphenate.chat.EMMessage.getBooleanAttribute | ( | String | attribute, |
boolean | defaultValue | ||
) |
Gets a message extension attribute of the Boolean type.
attribute | The attribute name. |
defaultValue | The default value of the attribute. |
EMChatThread com.hyphenate.chat.EMMessage.getChatThread | ( | ) |
Gets the overview of the message thread.
The overview of the message thread exists only after you creates a message thread.
ChatType com.hyphenate.chat.EMMessage.getChatType | ( | ) |
Gets the chat type.
double com.hyphenate.chat.EMMessage.getDoubleAttribute | ( | String | attribute | ) | throws HyphenateException |
Gets a message extension attribute of the double type.
attribute | The attribute name. |
HyphenateException | A description of the exception. See EMError. |
double com.hyphenate.chat.EMMessage.getDoubleAttribute | ( | String | attribute, |
double | defaultValue | ||
) |
Gets a message extension attribute of the Double type.
attribute | The attribute name. |
defaultValue | The default value of the attribute. |
float com.hyphenate.chat.EMMessage.getFloatAttribute | ( | String | attribute | ) | throws HyphenateException |
Gets a message extension attribute of the Float type.
attribute | The attribute name. |
HyphenateException | A description of the exception. See EMError. |
float com.hyphenate.chat.EMMessage.getFloatAttribute | ( | String | attribute, |
float | defaultValue | ||
) |
Gets a message extension attribute of the Float type.
attribute | The attribute name. |
defaultValue | The default value of the attribute. |
String com.hyphenate.chat.EMMessage.getFrom | ( | ) |
Gets the user ID of the message sender.
int com.hyphenate.chat.EMMessage.getIntAttribute | ( | String | attribute | ) | throws HyphenateException |
Gets a message extension attribute of the Int type.
attribute | The attribute name. |
HyphenateException | A description of the exception. See EMError. |
int com.hyphenate.chat.EMMessage.getIntAttribute | ( | String | attribute, |
int | defaultValue | ||
) |
Gets a message extension attribute of the Int type.
attribute | The attribute name. |
defaultValue | The default value of the attribute. |
JSONArray com.hyphenate.chat.EMMessage.getJSONArrayAttribute | ( | String | attribute | ) | throws HyphenateException |
Gets a message extension attribute of the JSONArray type.
attribute | The attribute name. |
HyphenateException | A description of the exception. See EMError. |
JSONObject com.hyphenate.chat.EMMessage.getJSONObjectAttribute | ( | String | attribute | ) | throws HyphenateException |
Gets a message extension attribute of the JSONObject type.
attribute | The attribute name. |
HyphenateException | A description of the exception. See EMError. |
long com.hyphenate.chat.EMMessage.getLongAttribute | ( | String | attribute | ) | throws HyphenateException |
Gets a message extension attribute of the Long type.
attribute | The attribute name. |
HyphenateException | A description of the exception. See EMError. |
long com.hyphenate.chat.EMMessage.getLongAttribute | ( | String | attribute, |
long | defaultValue | ||
) |
Gets a message extension attribute of the Long type.
attribute | The attribute name. |
defaultValue | The default value of the attribute. |
List< EMMessageReaction > com.hyphenate.chat.EMMessage.getMessageReaction | ( | ) |
Gets the list of Reactions.
String com.hyphenate.chat.EMMessage.getMsgId | ( | ) |
Gets the message ID.
long com.hyphenate.chat.EMMessage.getMsgTime | ( | ) |
Gets the Unix timestamp when the server receives the message.
String com.hyphenate.chat.EMMessage.getRecaller | ( | ) |
Gets the ID of the user that recalls the message.
String com.hyphenate.chat.EMMessage.getStringAttribute | ( | String | attribute | ) | throws HyphenateException |
Gets a message extension attribute of the String type.
attribute | The attribute name. |
HyphenateException | A description of the exception. See EMError. |
String com.hyphenate.chat.EMMessage.getStringAttribute | ( | String | attribute, |
String | defaultValue | ||
) |
Gets a message extension attribute of the String type.
attribute | The attribute name. |
defaultValue | The default value of the attribute. |
String com.hyphenate.chat.EMMessage.getTo | ( | ) |
Gets the user ID of the message recipient:
Type com.hyphenate.chat.EMMessage.getType | ( | ) |
Gets the chat message type.
String com.hyphenate.chat.EMMessage.getUserName | ( | ) |
Gets the the other party of the message:
int com.hyphenate.chat.EMMessage.groupAckCount | ( | ) |
Gets the number of members that have read the group message.
boolean com.hyphenate.chat.EMMessage.isAcked | ( | ) |
Gets whether the message is read.
true
: Yes. -false
: No. boolean com.hyphenate.chat.EMMessage.isBroadcast | ( | ) |
Whether it is a global broadcast message for chat rooms under an app.
true
: Yes.false
: No.boolean com.hyphenate.chat.EMMessage.isChatThreadMessage | ( | ) |
Gets whether the message is a threaded message.
true
: Yes.false
: No. boolean com.hyphenate.chat.EMMessage.isContentReplaced | ( | ) |
Whether the message content has been replaced.
true
: Yes.false
: No.boolean com.hyphenate.chat.EMMessage.isDelivered | ( | ) |
Gets whether the message is successfully delivered.
true
: Yes. -false
: No. boolean com.hyphenate.chat.EMMessage.isDeliverOnlineOnly | ( | ) |
Checks whether the message is delivered only when the recipient(s) is/are online.
true
: The message is delivered only when the recipient(s) is/are online. If the recipient is offline, the message is discarded.false
: The message is delivered when the recipient(s) is/are online. If the recipient(s) is/are offline, the message will not be delivered to them until they get online. boolean com.hyphenate.chat.EMMessage.isListened | ( | ) |
Gets whether the voice message is listened.
true
: Yes.false
: No. boolean com.hyphenate.chat.EMMessage.isNeedGroupAck | ( | ) |
Sets whether read receipts are required for group messages.
true
: Yes;false
: No. boolean com.hyphenate.chat.EMMessage.isOnlineState | ( | ) |
Whether the message gets delivered to an online user.
This field is not stored in the local database. The value of this field is true
by default for messages read from the database or pulled from the server.
true
: Yes.false
: No. The recipient is offline. boolean com.hyphenate.chat.EMMessage.isUnread | ( | ) |
Checks whether the message is unread.
true
: Yes. -false
: No. long com.hyphenate.chat.EMMessage.localTime | ( | ) |
Gets the local timestamp of the message.
This method gets the timestamp when the message is created locally.
EMMessagePinInfo com.hyphenate.chat.EMMessage.pinnedInfo | ( | ) |
Gets message pinning information.
int com.hyphenate.chat.EMMessage.progress | ( | ) |
The progress for uploading or downloading a message attachment.
The upload or download progress is unavailable for the thumbnail of the message attachments.
List< String > com.hyphenate.chat.EMMessage.receiverList | ( | ) |
The recipient list of a targeted message.
void com.hyphenate.chat.EMMessage.setAcked | ( | boolean | isAcked | ) |
Sets whether the message is read.
The method is supposed to be called by the SDK instead of you.
isAcked | Whether the message is read: -true : Yes. -false : No. |
void com.hyphenate.chat.EMMessage.setAttribute | ( | String | attribute, |
boolean | value | ||
) |
Sets a message extension attribute of the Boolean type.
attribute | The attribute name. |
value | The attribute value. |
void com.hyphenate.chat.EMMessage.setAttribute | ( | String | attribute, |
double | value | ||
) |
Sets a message extension attribute of the Double type.
attribute | The attribute name. |
value | The attribute value. |
void com.hyphenate.chat.EMMessage.setAttribute | ( | String | attribute, |
float | value | ||
) |
Sets a message extension attribute of the Float type.
attribute | The attribute name. |
value | The attribute value. |
void com.hyphenate.chat.EMMessage.setAttribute | ( | String | attribute, |
int | value | ||
) |
Sets a message extension attribute of the Int type.
attribute | The attribute name. |
value | The attribute value. |
void com.hyphenate.chat.EMMessage.setAttribute | ( | String | attribute, |
JSONArray | value | ||
) |
Sets a message extension attribute of the JSONArray type.
attribute | The attribute name. |
value | The attribute value. |
void com.hyphenate.chat.EMMessage.setAttribute | ( | String | attribute, |
JSONObject | value | ||
) |
Sets a message extension attribute of the JSONObject type.
attribute | The attribute name. |
value | The attribute value. |
void com.hyphenate.chat.EMMessage.setAttribute | ( | String | attribute, |
long | value | ||
) |
Sets a message extension attribute of the Long type.
attribute | The attribute name. |
value | The attribute value. |
void com.hyphenate.chat.EMMessage.setAttribute | ( | String | attribute, |
String | value | ||
) |
Sets a message extension attribute of the String type.
attribute | The attribute name. |
value | The attribute value. |
void com.hyphenate.chat.EMMessage.setBody | ( | EMMessageBody | body | ) |
(Recommended)Sets the message body.
body | The message body. |
void com.hyphenate.chat.EMMessage.setChatType | ( | ChatType | chatType | ) |
Sets the chat type.
chatType | The chat type. See ChatType. |
void com.hyphenate.chat.EMMessage.setDeliverAcked | ( | boolean | isDeliverAcked | ) |
Sets whether the message is delivered to the peer user.
The method is supposed to be called by the SDK instead of you.
isDeliverAcked | - true : The message is delivered to the peer user.
|
void com.hyphenate.chat.EMMessage.setDelivered | ( | boolean | isDelivered | ) |
Sets whether the message is successfully delivered.
The method is supposed to be called by the SDK instead of you.
isDelivered | Whether the message is successfully delivered: -true : Yes. -false : No. |
void com.hyphenate.chat.EMMessage.setDirection | ( | Direct | dir | ) |
Sets the message direction.
dir | The message direction. See Direct. |
void com.hyphenate.chat.EMMessage.setFrom | ( | String | from | ) |
Sets the user ID of the message sender.
from | The user ID of the message sender. |
void com.hyphenate.chat.EMMessage.setGroupAckCount | ( | int | count | ) |
Sets the number of members that have read the group message.
count | The number of members that have read the group message. |
void com.hyphenate.chat.EMMessage.setIsChatThreadMessage | ( | boolean | isChatThreadMessage | ) |
Sets whether the message is a threaded message.
isChatThreadMessage | - true means set to a threaded message.
|
void com.hyphenate.chat.EMMessage.setIsNeedGroupAck | ( | boolean | need | ) |
Sets whether read receipts are required for group messages.
need | Whether read receipts are required for group messages.
|
void com.hyphenate.chat.EMMessage.setListened | ( | boolean | isListened | ) |
Sets whether the voice message is listened.
The method is supposed to be called by the SDK instead of you.
isListened | Whether the voice message is listened:
|
void com.hyphenate.chat.EMMessage.setLocalTime | ( | long | serverTime | ) |
Sets the local timestamp of the message.
This method sets the timestamp when the message is created locally.
serverTime | The local timestamp of the message. |
synchronized void com.hyphenate.chat.EMMessage.setMessageStatusCallback | ( | EMCallBack | callback | ) |
Sets the message status change callback.
After the callback is triggered, the UI will be refreshed.
callback | The callback triggered when the message status changes. |
void com.hyphenate.chat.EMMessage.setMsgId | ( | String | msgId | ) |
Sets the local message ID.
msgId | Sets the local message ID. |
void com.hyphenate.chat.EMMessage.setMsgTime | ( | long | msgTime | ) |
Sets the Unix timestamp when the server receives the message.
msgTime | The Unix timestamp when the server receives the message. |
void com.hyphenate.chat.EMMessage.setPriority | ( | EMChatRoomMessagePriority | priority | ) |
Sets the priority of the chat room message.
priority | The priority of the chat room message. |
void com.hyphenate.chat.EMMessage.setProgress | ( | int | progress | ) |
Sets the progress for uploading or downloading a message attachment.
Usually, you do not need to set the progress value. See EMMessage#progress().
progress | The progress for uploading or downloading the message attachment. The value range is [0,100]. |
void com.hyphenate.chat.EMMessage.setReceiverList | ( | List< String > | receiverList | ) |
Sets the recipient list of a targeted message.
This method is used only for groups and chat rooms. If this method is not called after a message is created, the message is sent to all members in the group or chat room.
receiverList | The recipient list of a targeted message. If you pass in null , the messages are sent to all members in the group or chat room. |
void com.hyphenate.chat.EMMessage.setStatus | ( | Status | status | ) |
Sets the message sending or reception status.
status | The message sending or reception status. |
void com.hyphenate.chat.EMMessage.setTo | ( | String | to | ) |
Sets the user ID of the message recipient.
to | The user ID of the message recipient. |
void com.hyphenate.chat.EMMessage.setUnread | ( | boolean | unread | ) |
Sets whether the message is unread.
It is recommended that you use EMConversation#markAllMessagesAsRead() to mark all messages in a conversation as read.
unread | Whether the message is unread.
|
Status com.hyphenate.chat.EMMessage.status | ( | ) |
Gets the message sending or reception status.