hyphenate_SDK3.0  3.8.5
hyphenatejavaIMSDK
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
com.hyphenate.chat.EMMessage Class Reference
Inheritance diagram for com.hyphenate.chat.EMMessage:

Classes

enum  ChatType
 
enum  Direct
 
class  EMCallbackHolder
 
enum  Status
 
enum  Type
 

Public Member Functions

Status status ()
 
 EMMessage (EMAMessage message)
 
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 setBody (EMMessageBody body)
 
void addBody (EMMessageBody body)
 
String getFrom ()
 
void setFrom (String from)
 
void setTo (String to)
 
String getTo ()
 
String getMsgId ()
 
void setMsgId (String msgId)
 
synchronized void setMessageStatusCallback (EMCallBack callback)
 
String toString ()
 
void setAttribute (String attribute, boolean value)
 
void setAttribute (String attribute, int value)
 
void setAttribute (String attribute, long 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)
 
int getIntAttribute (String attribute) throws HyphenateException
 
long getLongAttribute (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)
 
int describeContents ()
 
void writeToParcel (Parcel out, int flags)
 
Object clone () throws CloneNotSupportedException
 
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 ()
 

Static Public Member Functions

static EMMessage createSendMessage (Type type)
 
static EMMessage createReceiveMessage (Type type)
 
static EMMessage createTxtSendMessage (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 username)
 
static EMMessage createFileSendMessage (String filePath, String username)
 
static EMMessage createFileSendMessage (Uri filePath, String username)
 

Static Public Attributes

static final Parcelable.Creator< EMMessageCREATOR
 

Detailed Description

Message object, represent a sent/received message

Construct a new send text message

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

Construct a new receive text message

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

Member Function Documentation

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

Add a message body Only support add one now

Parameters
bodyThe message body
String com.hyphenate.chat.EMMessage.conversationId ( )

Get conversation id

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

Create a normal file send message

Parameters
filePathThe path of the file
usernameThe recipient(user or group) id
Returns
The message instance
static EMMessage com.hyphenate.chat.EMMessage.createFileSendMessage ( Uri  filePath,
String  username 
)
static

Create a normal file send message

Parameters
filePathThe path of the file
usernameThe recipient(user or group) id
Returns
The message instance
static EMMessage com.hyphenate.chat.EMMessage.createImageSendMessage ( String  filePath,
boolean  sendOriginalImage,
String  username 
)
static

Create a image send message

Parameters
filePathThe path of the image
sendOriginalImageWhether to send the original(if image greater than 100k sdk will be compressed)
usernameThe recipient(user or group) id
Returns
The message instance
static EMMessage com.hyphenate.chat.EMMessage.createImageSendMessage ( Uri  imgUri,
boolean  sendOriginalImage,
String  username 
)
static

Create a image send message

Parameters
imgUriThe uri of the image
sendOriginalImageWhether to send the original(if image greater than 100k sdk will be compressed)
usernameThe recipient(user or group) id
Returns
The message instance
static EMMessage com.hyphenate.chat.EMMessage.createLocationSendMessage ( double  latitude,
double  longitude,
String  locationAddress,
String  username 
)
static

Create a location send message

Parameters
latitudeThe latitude
longitudeThe longitude
locationAddressLocation details
usernameThe recipient(user or group) id
Returns
The message instance
static EMMessage com.hyphenate.chat.EMMessage.createReceiveMessage ( Type  type)
static

Create a new receive message

Parameters
typeThe message type
Returns
The message instance
static EMMessage com.hyphenate.chat.EMMessage.createSendMessage ( Type  type)
static

Create a new send message

Parameters
typeThe message type
Returns
The message instance
static EMMessage com.hyphenate.chat.EMMessage.createTxtSendMessage ( String  content,
String  username 
)
static

Create a text send message

Parameters
contentText content
usernameThe recipient(user or group) id
Returns
The message instance
static EMMessage com.hyphenate.chat.EMMessage.createVideoSendMessage ( String  videofilePath,
String  imageThumbPath,
int  timeLength,
String  username 
)
static

Create a video send message

Parameters
videofilePathThe path of the video file
imageThumbPathThe path of the thumbnail
timeLengthThe length of the video time, unit s
usernameThe recipient(user or group) id
Returns
The message instance
static EMMessage com.hyphenate.chat.EMMessage.createVideoSendMessage ( Uri  videofilePath,
String  imageThumbPath,
int  timeLength,
String  username 
)
static

Create a video send message

Parameters
videofilePathThe path of the video file
imageThumbPathThe path of the thumbnail
timeLengthThe length of the video time, unit s
usernameThe recipient(user or group) id
Returns
The message instance
static EMMessage com.hyphenate.chat.EMMessage.createVideoSendMessage ( Uri  videofilePath,
Uri  imageThumbPath,
int  timeLength,
String  username 
)
static

Create a video send message

Parameters
videofilePathThe path of the video file
imageThumbPathThe path of the thumbnail
timeLengthThe length of the video time, unit s
usernameThe recipient(user or group) id
Returns
The message instance
static EMMessage com.hyphenate.chat.EMMessage.createVoiceSendMessage ( String  filePath,
int  timeLength,
String  username 
)
static

Create a voice send message

Parameters
filePathThe path of the voice file
timeLengthThe time length of the voice(unit s)
usernameThe recipient(user or group) id
Returns
The message instance
static EMMessage com.hyphenate.chat.EMMessage.createVoiceSendMessage ( Uri  filePath,
int  timeLength,
String  username 
)
static

Create a voice send message

Parameters
filePathThe uri of the voice file
timeLengthThe time length of the voice(unit s)
usernameThe recipient(user or group) id
Returns
The message instance
Direct com.hyphenate.chat.EMMessage.direct ( )

The message direction

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

Get message extension, return type is Map&#60;String, Object&#62;

Returns
Return message extension, return type is Map&#60;String, Object&#62; Object can be Boolean, Integer, Long, Float, Double, String If the input is JsonObject or JsonArray, which use setAttribute(String attribute, JSONObject json) to passed in, the Map.Entry.value type is String
EMMessageBody com.hyphenate.chat.EMMessage.getBody ( )

Get message body

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

Get a boolean type extra attribute

Parameters
attributeAttribute key
Returns
Attribute value
Exceptions
HyphenateException
boolean com.hyphenate.chat.EMMessage.getBooleanAttribute ( String  attribute,
boolean  defaultValue 
)

Get a boolean type extra attribute

Parameters
attributeAttribute key
defaultValuethe default value you want
Returns
Attribute value
ChatType com.hyphenate.chat.EMMessage.getChatType ( )

Get chat type

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

Get the sender id

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

Get a int type extra attribute

Parameters
attributeAttribute key
defaultValueThe default value you want
Returns
Attribute value
int com.hyphenate.chat.EMMessage.getIntAttribute ( String  attribute) throws HyphenateException

Get a int type extra attribute

Parameters
attributeAttribute key
Returns
Attribute value
Exceptions
HyphenateException
JSONArray com.hyphenate.chat.EMMessage.getJSONArrayAttribute ( String  attribute) throws HyphenateException

Get a JSONArray type attribute

Parameters
attributeAttribute key
Returns
Attribute value
Exceptions
HyphenateException
JSONObject com.hyphenate.chat.EMMessage.getJSONObjectAttribute ( String  attribute) throws HyphenateException

Get a JSONObject type attribute

Parameters
attributeAttribute key
Returns
Attribute value
Exceptions
HyphenateException
long com.hyphenate.chat.EMMessage.getLongAttribute ( String  attribute,
long  defaultValue 
)

Get a long type extra attribute

Parameters
attributeAttribute key
defaultValueThe default value you want
Returns
Attribute value
long com.hyphenate.chat.EMMessage.getLongAttribute ( String  attribute) throws HyphenateException

Get long type extra attribute

Parameters
attributeAttribute key
Returns
Attribute value
Exceptions
HyphenateException
String com.hyphenate.chat.EMMessage.getMsgId ( )

Get message id

Returns
Message id
long com.hyphenate.chat.EMMessage.getMsgTime ( )

Get message timestamp(server time)

Returns
Message timestamp(server time)
String com.hyphenate.chat.EMMessage.getStringAttribute ( String  attribute) throws HyphenateException

Get a string type extra attribute

Parameters
attributeAttribute key
Returns
Attribute value
Exceptions
HyphenateException
String com.hyphenate.chat.EMMessage.getStringAttribute ( String  attribute,
String  defaultValue 
)

Get a string type extra attribute

Parameters
attributeAttribute key
defaultValueThe default value you want
Returns
Attribute value
String com.hyphenate.chat.EMMessage.getTo ( )

Get receiver name

Returns
Receiver name
Type com.hyphenate.chat.EMMessage.getType ( )

获取消息类型

Returns
消息类型

Get message chat type

Returns
Message chat type
String com.hyphenate.chat.EMMessage.getUserName ( )

Get the peer's id

Returns
Peer's id
int com.hyphenate.chat.EMMessage.groupAckCount ( )

Read ack number of group message

Returns
Read ack number of group message
boolean com.hyphenate.chat.EMMessage.isAcked ( )

whether to read ack by the other

Returns
whether to read
boolean com.hyphenate.chat.EMMessage.isDelivered ( )

Delivery Ack, check if the peer has received the message

Returns
Whether the peer has received the message
boolean com.hyphenate.chat.EMMessage.isListened ( )

Get whether the message has been listened

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

Message if need group read ack

Returns
True: need group read ack; False: not need group read ack
boolean com.hyphenate.chat.EMMessage.isUnread ( )

Check if the message has been read

Returns
Whether the message has been read
long com.hyphenate.chat.EMMessage.localTime ( )

Get local timestamp

Returns
Local timestamp
int com.hyphenate.chat.EMMessage.progress ( )

Indicate message attachment upload or download progress, value ranges between 0-100 For message attachment's thumbnail, it doesn't has progress information

Returns
progress value
void com.hyphenate.chat.EMMessage.setAcked ( boolean  isAcked)

Sets whether the other has been read Not supposed to be called by app

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

Set a boolean type extra attributes of the message

Parameters
attributeAttribute key
valueAttribute value
void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
int  value 
)

Set a int type extra attributes of the message

Parameters
attributeAttribute key
valueAttribute value
void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
long  value 
)

Set a long type extra attributes of the message

Parameters
attributeAttribute key
valueAttribute value
void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
JSONObject  value 
)

Set a JSONObject type extra attributes of the message

Parameters
attributeAttribute key
valueAttribute value
void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
JSONArray  value 
)

Set a JSONArray type extra attributes of the message

Parameters
attributeAttribute key
valueAttribute value
void com.hyphenate.chat.EMMessage.setAttribute ( String  attribute,
String  value 
)

Set a string type extra attributes of the message

Parameters
attributeAttribute key
valueAttribute value
void com.hyphenate.chat.EMMessage.setBody ( EMMessageBody  body)

set message body

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

Set chat type The default is single chat ChatType#Chat

Parameters
chatTypesee ChatType
void com.hyphenate.chat.EMMessage.setDeliverAcked ( boolean  isDeliverAcked)

Set message deliver ack Not supposed to be called by app

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

Sets whether the message has been delivered Not supposed to be called by app

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

Set message direction

Parameters
dirMessage direction, see Direct
void com.hyphenate.chat.EMMessage.setFrom ( String  from)

Set message sender id

Parameters
fromSender id
void com.hyphenate.chat.EMMessage.setGroupAckCount ( int  count)

Set read ack number of group message

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

Set message if need group read ack

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

Sets whether the other has been listened

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

Set message local time

Parameters
serverTimeMessage local time
synchronized void com.hyphenate.chat.EMMessage.setMessageStatusCallback ( EMCallBack  callback)

Set message status callback Your app should set emaObject callback to get message status and then refresh the ui accordingly

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

Set local message id

Parameters
msgIdMessage id
void com.hyphenate.chat.EMMessage.setMsgTime ( long  msgTime)

Set message timestamp (server time)

Parameters
msgTimeMessage timestamp (server time)
void com.hyphenate.chat.EMMessage.setProgress ( int  progress)

Set message attachment upload or download progress, value ranges between 0-100 For app developing, it doesn't need to set progress

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

Set the status of the message

Parameters
statusStatus of the message
void com.hyphenate.chat.EMMessage.setTo ( String  to)

Sets the receiver ID of the message

Parameters
toThe receiver ID
Status com.hyphenate.chat.EMMessage.status ( )

Get the send/receive status of message

Returns
Send/receive status of message

Member Data Documentation

final Parcelable.Creator<EMMessage> com.hyphenate.chat.EMMessage.CREATOR
static
Initial value:
= new Parcelable.Creator<EMMessage>() {
public EMMessage createFromParcel(Parcel in) {
EMMessage msg = null;
try {
msg = new EMMessage(in);
} catch (HyphenateException e) {
e.printStackTrace();
}
return msg;
}
public EMMessage[] newArray(int size) {
return new EMMessage[size];
}
}

The documentation for this class was generated from the following file: