hyphenate_SDK3.0 3.7.6.3
hyphenate java IM SDK
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:
com.hyphenate.chat.EMBase< EMAMessage >

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 ()
 
- Public Member Functions inherited from com.hyphenate.chat.EMBase< EMAMessage >
boolean equals (Object o)
 
int hashCode ()
 

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
 

Additional Inherited Members

- Protected Attributes inherited from com.hyphenate.chat.EMBase< EMAMessage >
emaObject
 

Detailed Description

represent a sent/recv 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 recv text message

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

Member Function Documentation

◆ addBody()

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

add a message body,only support add one now

Parameters
bodythe message body

◆ createFileSendMessage() [1/2]

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 id
Returns

◆ createFileSendMessage() [2/2]

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 id
Returns

◆ createImageSendMessage() [1/2]

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 id
Returns

◆ createImageSendMessage() [2/2]

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 id
Returns

◆ createLocationSendMessage()

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 id
Returns

◆ createReceiveMessage()

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

create a new recv message

Parameters
typemessage type
Returns
the message object

◆ createSendMessage()

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

create a new send message

Parameters
typethe message type
Returns
the message object

◆ createTxtSendMessage()

static EMMessage com.hyphenate.chat.EMMessage.createTxtSendMessage ( String  content,
String  username 
)
static
Parameters
contenttext content
usernamethe recipient(user or group) id
Returns

◆ createVideoSendMessage() [1/3]

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 id
Returns

◆ createVideoSendMessage() [2/3]

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 id
Returns

◆ createVideoSendMessage() [3/3]

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 id
Returns

◆ createVoiceSendMessage() [1/2]

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 id
Returns

◆ createVoiceSendMessage() [2/2]

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 id
Returns

◆ direct()

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

the message direction

◆ ext()

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.

◆ getBody()

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

get message body

Returns

◆ getBooleanAttribute() [1/2]

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

get a boolean type extra attribute

Parameters
attributethe attribute name return
Exceptions
HyphenateException

◆ getBooleanAttribute() [2/2]

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

get a boolean type extra attribute

Parameters
attributethe attribute name
defaultValuethe default value you want
Returns

◆ getChatType()

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

get chat type

Returns
ChatType

◆ getFrom()

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

get the sender id

Returns
user id

◆ getIntAttribute() [1/2]

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

get a int type extra attribute

Parameters
attributethe attribute name
Returns
the value
Exceptions
HyphenateException

◆ getIntAttribute() [2/2]

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

get a int type extra attribute

Parameters
attributethe attribute name
defaultValuethe default value you want
Returns

◆ getJSONArrayAttribute()

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

get a jsonarray type attribute

Parameters
attribute
Returns
the value
Exceptions
HyphenateException

◆ getJSONObjectAttribute()

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

get a jsonobject type attribute

Parameters
attribute
Returns
the value
Exceptions
HyphenateException

◆ getLongAttribute() [1/2]

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

get long type extra attribute

Parameters
attributethe attribute name
Returns
the value
Exceptions
HyphenateException

◆ getLongAttribute() [2/2]

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

get a long type extra attribute

Parameters
attributethe attribute name
defaultValuethe default value you want
Returns

◆ getMsgId()

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

get message id

Returns
id

◆ getMsgTime()

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

get message time stamp(server time)

Returns

◆ getStringAttribute() [1/2]

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

get a string type extra attribute

Parameters
attributethe attribute name
Returns
the value
Exceptions
HyphenateException

◆ getStringAttribute() [2/2]

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

get a string type extra attribute

Parameters
attributethe attribute name
defaultValuethe default value you want
Returns

◆ getTo()

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

get receiver name

Returns

◆ getType()

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

\chinese 获取消息类型

Returns

get message chat type

Returns

◆ getUserName()

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

get the peer's id

◆ groupAckCount()

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

read ack number of group message

Parameters

◆ isAcked()

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

Read Ack

◆ isDelivered()

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

Delivery Ack, check if the peer has received the message

◆ isListened()

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

get whether the message is listen

◆ isNeedGroupAck()

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

message if need group read ack

Parameters

◆ isUnread()

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

unread flag

◆ localTime()

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

get local receive time

Returns

◆ progress()

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

◆ setAcked()

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

Sets whether the other has been read, not suppposed to be called by app

◆ setAttribute() [1/6]

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

set a boolean type extra attributes of the message

Parameters
attributeattribute key
valueattribute value

◆ setAttribute() [2/6]

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

set a int type extra attributes of the message

Parameters
attributeattribute key
valueattribute value

◆ setAttribute() [3/6]

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

set a jsonarray type extra attributes of the message

Parameters
attributeattribute key
valueattribute value

◆ setAttribute() [4/6]

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

set a jsonobject type extra attributes of the message

Parameters
attributeattribute key
valueattribute value

◆ setAttribute() [5/6]

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

set a long type extra attributes of the message

Parameters
attributeattribute key
valueattribute value

◆ setAttribute() [6/6]

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

set a string type extra attributes of the message

Parameters
attributeattribute key
valueattribute value

◆ setBody()

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

set message body

Parameters
body

◆ setChatType()

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

set chat type, the default is single chat ChatType.Chat

Parameters
chatType
See also
ChatType

◆ setDirection()

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

set message direction

Parameters
dir

◆ setFrom()

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

set sender id

Parameters
from

◆ setGroupAckCount()

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

set read ack number of group message

Parameters

◆ setIsNeedGroupAck()

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

set message if need group read ack

Parameters
need

◆ setListened()

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

Sets whether the other has been listen

Parameters
isListened

◆ setLocalTime()

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

set message local receive time

Parameters
serverTime

◆ setMessageStatusCallback()

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

◆ setMsgId()

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

set local message id

Parameters
msgId

◆ setMsgTime()

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

set message time stamp(server time)

Parameters
msgTime

◆ setProgress()

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

for app developing, it doesn't need set progress.

Parameters
progress

◆ setStatus()

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

set the status of the message

◆ setTo()

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

set receiver name

Parameters
to

◆ status()

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

message status

Member Data Documentation

◆ CREATOR

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: