public class EMChatManager
extends java.lang.Object
public final class YouAppClass extends Application { public void onCreate() { super.onCreate(); // 初始化 chat sdk EMChat.getInstance().init(this.getApplicationContext()); } }发送一条文本消息:
EMMessage msg = new EMMessage(EMMessage.Type.TXT); msg.setReceipt("test_user1"); TextMessageBody body = new TextMessageBody("hello from easemob"); msg.addBody(body); EMChatManager.getInstance().sendMessage(msg);从接收消息通过注册broadcast receiver实现::
BroadcastReceiver msgReceiver = new BroadcastReceiver(){ public void onReceive(Context context, Intent intent) { String msgId = intent.getStringExtra("msgid"); EMMessage message = EMChatManager.getInstance().getMessage(msgId); Log.d("main", "new message id:" + msgId + " from:" + message.getFrom() + " type:" + message.getType() + " body:" + message.getBody()); switch (message.getType()) { case TXT: TextMessageBody txtBody = (TextMessageBody)message.getBody(); Log.d("text message from:" + message.getFrom() + " text:" + txtBody.getMessage() + " \n\r"); break; case IMAGE: ImageMessageBody imgBody = (ImageMessageBody)message.getBody(); Log.d("img message from:" + message.getFrom() + " thumbnail:" + imgBody.getThumbnailUrl() + " remoteurl:" + imgBody.getRemoteUrl()+ " \n\r"); break; case VOICE: VoiceMessageBody voiceBody = (VoiceMessageBody)message.getBody(); Log.d("voice message from:" + message.getFrom() + " length:" + voiceBody.getLength() + " remoteurl:" + voiceBody.getRemoteUrl()+ " \n\r"); break; case LOCATION: LocationMessageBody locationBody = (LocationMessageBody)message.getBody(); Log.d("location message from:" + message.getFrom() + " address:" + locationBody.getAddress() +" \n\r"); break; } }; IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); registerReceiver(msgReceiver, intentFilter);应用程序可以通过EMChatOptions 来配置聊天的各种选项
EMChatOptions
限定符和类型 | 方法和说明 |
---|---|
void |
acceptInvitation(java.lang.String username)
已过时。
|
void |
ackMessageRead(java.lang.String to,
java.lang.String messageId)
发送消息已读回执
send read ack to server
|
void |
activityResumed()
应用从后台回到前台,需要用activityResumed 通知sdk sdk 会reset 系统的消息通知 (notification area)
|
void |
addCallStateChangeListener(EMCallStateChangeListener listener)
设置通话状态监听
|
void |
addChatRoomChangeListener(EMChatRoomChangeListener listener)
注册聊天室事件监听
register chat room change listener
|
void |
addConnectionListener(ConnectionListener listener)
已过时。
please use new API
addConnectionListener(final
EMConnectionListener listener) instead |
void |
addConnectionListener(EMConnectionListener listener)
add the connection listener to monitor the connection state APP should
not update the UI directly in the callback functions defined in
EMConnectionListener
|
void |
addVoiceCallStateChangeListener(EMCallStateChangeListener listener)
|
void |
answerCall()
接听通话
|
boolean |
areAllConversationsLoaded() |
void |
asyncFetchMessage(EMMessage msg)
未成功下载的附件,可再次下载
|
void |
asyncLoadAllConversations(EMCallBack callback)
asynchronously load all conversations with number of messages specificed in setNumberOfMessagesLoaded in
EMChatOptions for each conversation,20 by defalult
异步获取所有会话列表,每个会话默认加载的消息条目由setNumberOfMessagesLoaded指定,可以参考EMChatOptions ,默认是20条以保持兼容,建议是1 |
boolean |
clearConversation(java.lang.String username)
清空和指定用户或者群聊的会话(包括删除本地的聊天记录)
和deleteConversation的区别是: 这个会保留conversation这个对象, 当用户处于聊天页面或者类似上一页是聊天页面,清空消息时务必调用此方法,否则 清空后再来此用户的消息,ui上会有bug |
void |
createAccountOnServer(java.lang.String username,
java.lang.String password)
创建新的用户 因为需要网络访问,此方法需要运行在单独的线程或AsyncTask中
create a new easemob user account and this api is only supported when you mark your app as unauthorized user registration in easemob management console
|
void |
deleteAllConversation()
删除所有会话
delete all conversations and all message history
|
boolean |
deleteConversation(java.lang.String username)
删除和指定用户的对话(包括删除本地的聊天记录)
delete conversation and all message history in this conversation
|
boolean |
deleteConversation(java.lang.String username,
boolean isGroup)
删除和指定用户或者群聊的对话(包括删除本地的聊天记录)
delete conversation and all history messages
|
boolean |
deleteConversation(java.lang.String username,
boolean isGroup,
boolean deleteMessages)
删除和指定用户或者群聊的对话(包括删除本地的聊天记录)
delete conversation and optionally delete all history messages
|
void |
disconnect()
this api is not supposed to be public to all
|
void |
downloadFile(java.lang.String remoteUrl,
java.lang.String localFilePath,
java.util.Map<java.lang.String,java.lang.String> headers,
EMCallBack callback)
从环信服务器下载文件
download the file from eaemob server
|
void |
endCall()
挂断通话
|
EMChatRoom |
fetchChatRoomFromServer(java.lang.String roomId)
从服务器获取聊天室详情
耗时操作
fetch the chat room by room id
|
EMPageResult<EMChatRoom> |
fetchPublicChatRoomsFromServer(int pageNum,
int pageSize)
分页从服务器获取聊天室
耗时操作
fetch the chatroom in page synchronoulsy
this is a time consuming ooperation
|
EMCursorResult<EMChatRoom> |
fetchPublicChatRoomsFromServer(int pageSize,
java.lang.String cursor)
已过时。
use fetchPublicChatRoomsFromServer(int pageNum, int pageSize)
|
java.lang.String |
getAccessToken()
获取身份认证权限 在上传下载附件(语音,图片,文件等)时必须添加到请求header中 当出现任何异常时将返回null,
可通过判断是否为null来检测是否有问题 如果为null,在打开EMLog日志时,是可以看到异常原因。
|
java.lang.String |
getAckMessageBroadcastAction()
已过时。
please use
registerEventListener instead |
java.util.List<EMChatRoom> |
getAllChatRooms()
从内存中获取所有的聊天室
非耗时操作
get all the chat rooms in the cache
|
java.util.Hashtable<java.lang.String,EMConversation> |
getAllConversations()
获取内存中所有会话
和loadAllConversations区别就是loadAllConversations是从本地数据库加载所有的会话到内存,所以app在使用getAllConversations之前,一定要先调用loadAllConversations
以确保会话都被加载到内存中,不过loadAllConversations调用一次即可
get all conversations
compared with loadAllConversations, loadAllConversations will load conversations from db to memory and getAllConversations will get all conversations from memmory
therefore, you should call api loadAllConversations and getAllConversations
|
EMChatOptions |
getChatOptions()
获取聊天sdk 的相关参数,配置
get options
|
EMChatRoom |
getChatRoom(java.lang.String roomId)
从内存中获取聊天室
非耗时操作
get the chat room in the cache
|
java.lang.String |
getCmdMessageBroadcastAction()
已过时。
please use
registerEventListener instead |
java.lang.String |
getContactInviteEventBroadcastAction() |
java.util.List<java.lang.String> |
getContactUserNames()
获取所有联系人的用户名列表
|
EMConversation |
getConversation(java.lang.String username)
获取和指定用户或者群组的对话
get conversation through user id or group id
typically you don't need to pass any type of conversation to get the conversation if you don't work on the chatroom
otherwise you should pass by the conversation type
getConversationByType(String username, EMConversationType type) |
EMConversation |
getConversation(java.lang.String username,
boolean isGroup)
已过时。
已过时,请使用
#getConversation(String, ChatType) 替代 |
EMConversation |
getConversationByType(java.lang.String username,
EMConversation.EMConversationType type)
please use this api to get conversation in case you want to get conversation for chatroom type
|
java.util.List<EMConversation> |
getConversationsByType(EMConversation.EMConversationType type)
get list of conversations by conversation type
|
java.util.List<java.lang.String> |
getConversationsUnread()
获取有未读数的会话
get list of user id of group id which have the unread messages
|
java.lang.String |
getCurrentUser()
获取当前登录用户的用户名
get current logged in user id
|
java.lang.String |
getDeliveryAckMessageBroadcastAction()
已过时。
please use
registerEventListener instead |
EncryptProvider |
getEncryptProvider()
获取EncryptProvider 如果未设置, 将返回sdk 内置的encrypt provider
|
java.lang.String |
getIncomingCallBroadcastAction()
获取音视频通话广播的action
|
java.lang.String |
getIncomingVoiceCallBroadcastAction()
已过时。
|
static EMChatManager |
getInstance()
获取EMChatManager全局单例
get global EMChatManager instance
|
java.util.Map<java.lang.String,EMKeywordSearchInfo> |
getKeywordInfoList(java.lang.String keyword)
全局搜索聊天内容,如果一个会话有多条,会通过数字提示
get the keyword info list by keyword
|
EMMessage |
getMessage(java.lang.String messageId)
获取指定ID 的消息对象
get message through message id
|
java.util.List<EMMessage> |
getMessagesByKeyword(java.lang.String keyword,
java.lang.String startMsgId,
int pageNumber,
java.lang.String username)
根据某用户搜索得到详细的消息列表
get message list in page by keyword for specific user
|
java.util.List<EMMessage> |
getMessagesByMsgType(EMMessage.Type messageType,
EMMessage.ChatType chatType,
java.lang.String userName,
java.lang.String startMessageId,
int num)
返回单聊(群聊)下的某一类型的消息列表
|
java.lang.String |
getNewMessageBroadcastAction()
已过时。
please use
registerEventListener instead |
java.lang.String |
getOfflineMessageBroadcastAction()
已过时。
please use
registerEventListener instead |
java.util.List<EMContact> |
getRobotsFromServer()
获取Robot列表
|
long |
getTotalMessageCountByMsgType(EMMessage.Type messageType,
EMMessage.ChatType chatType,
java.lang.String userName)
返回单聊(群聊)下的某一类型的消息总数
|
int |
getUnreadMsgsCount()
获取未读消息计数
get unread mesage count
|
int |
getVoiceInputLevel()
获取通话时声音输入的大小(范围0-9)
|
java.lang.String |
importMessage(EMMessage message,
boolean addToMemory)
向消息数据库导入一条聊天记录
|
void |
importMessages(java.util.List<EMMessage> msgs)
向消息数据库导入多条聊天记录
在调用次函数时要保证,消息的发送方或者接收方是当前用户
已经对函数做过速度优化, 推荐一次导入1000条数据
|
boolean |
isConnected()
检查是否连接到聊天服务器
check if we are connected.
|
boolean |
isDirectCall()
返回当前通话时是否为P2P直连
check if that's a P2P call
|
boolean |
isSlientMessage(EMMessage message)
判断是否是免打扰的消息
check if the message is kind of slient message, if that's it, app should not play tone or vibrate
|
void |
joinChatRoom(java.lang.String roomId,
EMValueCallBack<EMChatRoom> callback)
加入聊天室
join the chat room asynchronously
example:
public void api_joinChatRoom(final String roomId){
new Thread(){
|
void |
leaveChatRoom(java.lang.String roomId)
离开聊天室,SDK保证聊天室退出成功,无论网络情况如何
leave chat room and sdk will ensure leaving is successful whenever what happens, for example, no network.
|
void |
loadAllConversations()
同步加载所有的会话,并且每条会话读入EMChatOptions.getNumberOfMessagesLoaded()条消息, 默认是20条以保持兼容
APP可以在用EMChatOptions.setNumberOfMessagesLoaded去设置初始条数(建议是1)
|
void |
loadAllConversations(EMCallBack callback)
已过时。
过时请使用
asyncloadAllConversations(EMCallBack callback) instead |
void |
login(java.lang.String username,
java.lang.String password,
EMCallBack callback)
登陆到聊天服务器
环信郑重提示此login函数是用来登录环信账号的初始化API,在回调函数没有返回的情况下重复多次调用此函数会导致负面的影响
自动登录的情况下(就是之前登录过从没注销过),无需再次调用此函数,在这种情况下,客户端可以通过监听连接回调函数
addConnectionListener(final EMConnectionListener listener) ,来进一步处理连接成功后的业务
login to easemob server
Please try to call this api again until last call to this api is returned, otherwise multiple calls to this api will cause side effect. |
void |
logout()
此方法改成同步登出聊天服务器
如果需要异步请参考
logout(final EMCallBack callback)
logout easemob IM server synchronously
in case if you need an asynchronously API, please use logout(final EMCallBack callback) |
int |
logout(boolean isUnbindDeviceToken)
此方法改成同步登出聊天服务器(国际化)
如果需要异步请参考
logout(final boolean isUnbindDeviceToken,final EMCallBack callback)
logout synchronously and support GCM push |
void |
logout(boolean isUnbindDeviceToken,
EMCallBack callback)
异步登出聊天服务器(国际化)
请等待callback回调,再继续做和环信sdk相关的操作
|
void |
logout(EMCallBack callback)
异步登出聊天服务器
请等待callback回调,再继续做和环信sdk相关的操作
logout easemob IM server asynchronously
|
void |
makeVideoCall(java.lang.String to)
拨打视频通话
|
void |
makeVoiceCall(java.lang.String to)
拨打语音通话
|
void |
markAllConversationsAsRead()
把所有的会话都设成已读
mark all messages as unread
|
void |
onEnterForeground()
suggest to call this api when app enter the foreground
that means the app should override the onResume in activity and to call this api
|
void |
onReconnectionSuccessful() |
void |
pauseVideoTransfer()
实时通话时停止视频数据传输
|
void |
pauseVoiceTransfer()
实时通话时暂停语音数据传输
|
void |
reconnect()
reconnect to IM server
the precondation is app should be logged in
|
void |
refuseInvitation(java.lang.String username)
|
void |
registerEventListener(EMEventListener listener)
注册消息事件监听,此listener会收到所有类型的event事件,如果对某种或某些类型的事件感兴趣,可以用
registerEventListener(EMEventListener listener, EMNotifierEvent.EventType[] types)
register the event listener |
void |
registerEventListener(EMEventListener listener,
EMNotifierEvent.Event[] events)
注册对某些消息事件类型感兴趣的监听,SDK只会给注册这种类型的listener发通知
reister the event listener which is interested in some specific events
|
void |
rejectCall()
拒绝接听
|
void |
removeCallStateChangeListener(EMCallStateChangeListener listener)
移除通话监听
|
void |
removeChatRoomChangeListener(EMChatRoomChangeListener listener)
移除聊天室事件监听
remove chat room change listener
|
void |
removeConnectionListener(ConnectionListener listener)
已过时。
use {@link removeConnectionListener(EMConnectionListener
listener) instead
|
void |
removeConnectionListener(EMConnectionListener listener)
移除 connection listener
remove connection listener
|
void |
resetAllUnreadMsgCount()
已过时。
|
void |
resumeVideoTransfer()
实时通话时恢复视频数据传输
|
void |
resumeVoiceTransfer()
实时通话时恢复语音数据传输
|
void |
saveMessage(EMMessage message)
保存用户app 生成的消息,比如系统提示 消息会存到内存中的conversation 和数据库
save the message to memory and db
|
void |
saveMessage(EMMessage message,
boolean unreadcountIncrease)
保存用户app 生成的消息,比如系统提示 消息会存到内存中的conversation 和数据库
|
void |
sendGroupMessage(EMMessage msg,
EMCallBack callback)
已过时。
已过时,请使用
sendMessage(EMMessage, EMCallBack) 替代, |
void |
sendMessage(EMMessage msg)
异步发送消息 如果是语音,图片类有附件的消息,sdk 会自动上传附件
send message asynchronously and since SDK v2.2.2, msg status change notification will be notifyied through EMMessage status callback
and you can set this message status callback through EMMessage.setMessageStatusCallback
|
void |
sendMessage(EMMessage msg,
EMCallBack callback)
异步发送消息, 通过回调通知用户发送状态
|
void |
setAdaptiveVideoFlag(boolean enable)
视频通话时是否自动调节码率,默认是false
|
void |
setChatOptions(EMChatOptions chatOptions)
设置聊天sdk 的相关参数,配置 可以在应用启动的时候设置相应的值。
|
void |
setEncryptProvider(EncryptProvider provider)
设置应用的加密实现 如果未设置,SDK 会使用内置的加密算法
set the encrypt provider.
|
void |
setGCMProjectNumber(java.lang.String projectNumber)
for GCM support, to set GCM number
|
void |
setHuaweiPushAppId(java.lang.String appId)
设置用于华为推送的appid
|
void |
setMessageListened(EMMessage message)
mark the audio/video message has been listened
|
void |
setMipushConfig(java.lang.String mipushAppid,
java.lang.String mipushAppkey)
设置用于小米推送的appid和appkey
|
void |
unregisterEventListener(EMEventListener listener)
移除消息事件监听
remove the event listener
|
boolean |
updateCurrentUserNick(java.lang.String nickname)
已过时。
use
updateCurrentUserNick(String, boolean) instead |
boolean |
updateCurrentUserNick(java.lang.String nickname,
boolean showPushMsgDetails)
更新当前用户的nickname
此方法主要为了在苹果推送及小米推送、gcm推送消息时,客户端能够显示nick而不是userid, 一般可以在登陆成功后从自己服务器获取到个人信息,然后拿到nick更新到环信服务器 并且,在个人信息中如果更改个人的昵称,也要把环信服务器更新下nickname 防止显示差异 |
boolean |
updateMessageBody(EMMessage message)
更新消息体 更新消息体,消息体的内容会被保存到本地
|
public void login(java.lang.String username, java.lang.String password, EMCallBack callback)
addConnectionListener(final EMConnectionListener listener)
,来进一步处理连接成功后的业务
login to easemob server
Please try to call this api again until last call to this api is returned, otherwise multiple calls to this api will cause side effect.
for automatic login - did not logout once loggged in before, the app should monitor the conneciton status by adding conneciton listener through addConnectionListener(final EMConnectionListener listener)
username
- 用户名password
- 密码callback
- 回调函数, 如果是null,会报IllegalArgumentException异常。public void logout()
logout(final EMCallBack callback)
logout easemob IM server synchronously
in case if you need an asynchronously API, please use logout(final EMCallBack callback)
public void logout(EMCallBack callback)
callback
- logout执行完毕后的回调public void logout(boolean isUnbindDeviceToken, EMCallBack callback)
callback
- logout执行完毕后的回调isUnbindDeviceToken
- 是否移除之前绑定的push device tokenjava.lang.RuntimeException
- if callback is null, will throw RuntimeExceptionpublic int logout(boolean isUnbindDeviceToken)
logout(final boolean isUnbindDeviceToken,final EMCallBack callback)
logout synchronously and support GCM pushisUnbindDeviceToken
- public void createAccountOnServer(java.lang.String username, java.lang.String password) throws com.easemob.exceptions.EaseMobException
username
- 用户名password
- 密码com.easemob.exceptions.EaseMobException
public boolean isConnected()
public void registerEventListener(EMEventListener listener)
registerEventListener(EMEventListener listener, EMNotifierEvent.EventType[] types)
register the event listenerlistener
- see EMEventListener
public void registerEventListener(EMEventListener listener, EMNotifierEvent.Event[] events)
listener
- EMEventListener
types
- 关注的event类型 see EMNotifierEvent.EventType
the interested event typespublic void unregisterEventListener(EMEventListener listener)
listener
- public static EMChatManager getInstance()
public void acceptInvitation(java.lang.String username) throws com.easemob.exceptions.EaseMobException
EMContactManager.acceptInvitation(String)
替代,username
- com.easemob.exceptions.EaseMobException
public void refuseInvitation(java.lang.String username) throws com.easemob.exceptions.EaseMobException
username
- com.easemob.exceptions.EaseMobException
public void sendMessage(EMMessage msg) throws com.easemob.exceptions.EaseMobException
msg
- 待发送消息对象com.easemob.exceptions.EaseMobException
- 网络错误或其它异常public void sendMessage(EMMessage msg, EMCallBack callback)
msg
- 待发送消息callback
- 发送进度/状态回调函数com.easemob.exceptions.EaseMobException
- 网络错误或其它异常public void sendGroupMessage(EMMessage msg, EMCallBack callback)
sendMessage(EMMessage, EMCallBack)
替代,msg
- 待发送消息callback
- 发送进度/状态回调函数com.easemob.exceptions.EaseMobException
- 网络错误或其它异常public java.lang.String getNewMessageBroadcastAction()
registerEventListener
insteadpublic java.lang.String getCmdMessageBroadcastAction()
registerEventListener
insteadpublic java.lang.String getAckMessageBroadcastAction()
registerEventListener
insteadpublic java.lang.String getDeliveryAckMessageBroadcastAction()
registerEventListener
insteadpublic java.lang.String getContactInviteEventBroadcastAction()
public java.lang.String getOfflineMessageBroadcastAction()
registerEventListener
insteadpublic java.lang.String getIncomingVoiceCallBroadcastAction()
getIncomingCallBroadcastAction()
替代public java.lang.String getIncomingCallBroadcastAction()
public void ackMessageRead(java.lang.String to, java.lang.String messageId) throws com.easemob.exceptions.EaseMobException
to
- 接收方的用户名messageId
- 消息的IDcom.easemob.exceptions.EaseMobException
public void setMessageListened(EMMessage message)
message
- public void addConnectionListener(ConnectionListener listener)
addConnectionListener(final
EMConnectionListener listener)
insteadlistener
- public void addConnectionListener(EMConnectionListener listener)
listener
- public void removeConnectionListener(ConnectionListener listener)
listener
- public void removeConnectionListener(EMConnectionListener listener)
listener
- public EMMessage getMessage(java.lang.String messageId)
messageId
- 消息IDpublic EMConversation getConversation(java.lang.String username)
getConversationByType(String username, EMConversationType type)
username
- 用户名或者群组idpublic EMConversation getConversation(java.lang.String username, boolean isGroup)
#getConversation(String, ChatType)
替代username
- 用户名或者群组idisGroup
- 指定明确会话类型,true为群聊public EMConversation getConversationByType(java.lang.String username, EMConversation.EMConversationType type)
public boolean deleteConversation(java.lang.String username)
username
- 用户名public void deleteAllConversation()
public void resetAllUnreadMsgCount()
markAllConversationsAsRead()
public void markAllConversationsAsRead()
public boolean deleteConversation(java.lang.String username, boolean isGroup)
username
- 用户名或者群聊idisGroup
- 是否为群聊(群组或者聊天室)会话public boolean deleteConversation(java.lang.String username, boolean isGroup, boolean deleteMessages)
username
- 用户名或者群聊idisGroup
- 是否为群聊(群组或者聊天室)会话deleteMessages
- 删除该会话的全部消息记录public boolean clearConversation(java.lang.String username)
username
- 用户名或群聊idpublic void loadAllConversations(EMCallBack callback)
asyncloadAllConversations(EMCallBack callback)
insteadcallback
- public void asyncLoadAllConversations(EMCallBack callback)
EMChatOptions
for each conversation,20 by defalult
异步获取所有会话列表,每个会话默认加载的消息条目由setNumberOfMessagesLoaded指定,可以参考EMChatOptions
,默认是20条以保持兼容,建议是1callback
- public void loadAllConversations()
public java.util.Hashtable<java.lang.String,EMConversation> getAllConversations()
public int getUnreadMsgsCount()
public void activityResumed()
public void saveMessage(EMMessage message)
message
- 待存储的消息public void saveMessage(EMMessage message, boolean unreadcountIncrease)
message
- 待存储的消息unreadcountIncrease
- 是否存入消息时未读数自动加1public boolean updateMessageBody(EMMessage message)
message
- public java.util.List<java.lang.String> getContactUserNames() throws com.easemob.exceptions.EaseMobException
com.easemob.exceptions.EaseMobException
public java.lang.String getCurrentUser()
public EMChatOptions getChatOptions()
public void setChatOptions(EMChatOptions chatOptions)
EMChatOptions
chatOptions
- 配置参数public void setEncryptProvider(EncryptProvider provider)
provider
- public EncryptProvider getEncryptProvider()
public void addVoiceCallStateChangeListener(EMCallStateChangeListener listener)
listener
- public void addCallStateChangeListener(EMCallStateChangeListener listener)
listener
- public void removeCallStateChangeListener(EMCallStateChangeListener listener)
listener
- public void makeVoiceCall(java.lang.String to) throws com.easemob.exceptions.EMServiceNotReadyException
to
- com.easemob.exceptions.EMServiceNotReadyException
public void answerCall() throws com.easemob.exceptions.EMNoActiveCallException, com.easemob.exceptions.EMNetworkUnconnectedException
com.easemob.exceptions.EMNoActiveCallException
com.easemob.exceptions.EMNetworkUnconnectedException
public void rejectCall() throws com.easemob.exceptions.EMNoActiveCallException
com.easemob.exceptions.EMNoActiveCallException
public void endCall()
public void makeVideoCall(java.lang.String to) throws com.easemob.exceptions.EMServiceNotReadyException
to
- com.easemob.exceptions.EMServiceNotReadyException
public void onReconnectionSuccessful()
public void asyncFetchMessage(EMMessage msg)
msg
- public java.lang.String importMessage(EMMessage message, boolean addToMemory)
message
- ,需要导入的messageaddToMemory
- 在内存里也保持此消息public void importMessages(java.util.List<EMMessage> msgs)
msgs
- 需要导入数据库的消息public boolean updateCurrentUserNick(java.lang.String nickname)
updateCurrentUserNick(String, boolean)
insteadnickname
- 昵称public boolean updateCurrentUserNick(java.lang.String nickname, boolean showPushMsgDetails)
nickname
- 用户昵称showPushMsgDetails
- 收到推送时是否显示消息内容public java.lang.String getAccessToken()
public java.util.List<java.lang.String> getConversationsUnread()
public boolean areAllConversationsLoaded()
public java.util.List<EMConversation> getConversationsByType(EMConversation.EMConversationType type)
public boolean isSlientMessage(EMMessage message)
message
- public void downloadFile(java.lang.String remoteUrl, java.lang.String localFilePath, java.util.Map<java.lang.String,java.lang.String> headers, EMCallBack callback)
remoteUrl
- 服务器上的远程文件localFilePath
- 本地要生成的文件headers
- Http Request Headercallback
- EMCallBackpublic void addChatRoomChangeListener(EMChatRoomChangeListener listener)
listener
- public void removeChatRoomChangeListener(EMChatRoomChangeListener listener)
listener
- public void joinChatRoom(java.lang.String roomId, EMValueCallBack<EMChatRoom> callback)
example:
public void api_joinChatRoom(final String roomId){ new Thread(){
roomId
- com.easemob.exceptions.EaseMobException
public void leaveChatRoom(java.lang.String roomId)
roomId
- 离开聊天室IDcom.easemob.exceptions.EaseMobException
public EMCursorResult<EMChatRoom> fetchPublicChatRoomsFromServer(int pageSize, java.lang.String cursor) throws com.easemob.exceptions.EaseMobException
pageSize
- 一次请求所要获取的聊天室的数量cursor
- 首次是null,否则是上次获取服务器返回的游标com.easemob.exceptions.EaseMobException
public EMPageResult<EMChatRoom> fetchPublicChatRoomsFromServer(int pageNum, int pageSize) throws com.easemob.exceptions.EaseMobException
pageNum
- 当前要拉取的页数,从1开始pageSize
- 当前要拉取的页的数量com.easemob.exceptions.EaseMobException
public EMChatRoom fetchChatRoomFromServer(java.lang.String roomId) throws com.easemob.exceptions.EaseMobException
roomId
- com.easemob.exceptions.EaseMobException
public EMChatRoom getChatRoom(java.lang.String roomId)
roomId
- public java.util.List<EMChatRoom> getAllChatRooms()
public java.util.List<EMContact> getRobotsFromServer() throws com.easemob.exceptions.EaseMobException
com.easemob.exceptions.EaseMobException
public void setGCMProjectNumber(java.lang.String projectNumber)
public void setMipushConfig(java.lang.String mipushAppid, java.lang.String mipushAppkey)
mipushAppid
- mipushAppkey
- public void setHuaweiPushAppId(java.lang.String appId)
appId
- public boolean isDirectCall()
public java.util.Map<java.lang.String,EMKeywordSearchInfo> getKeywordInfoList(java.lang.String keyword)
keyword
- 要搜索的内容public java.util.List<EMMessage> getMessagesByKeyword(java.lang.String keyword, java.lang.String startMsgId, int pageNumber, java.lang.String username)
chatType
- 会话类型(单聊或群聊)keyword
- 要搜索的内容startMsgId
- 分页加载idpageNumber
- 分页加载数username
- 用户名public void pauseVoiceTransfer()
public void resumeVoiceTransfer()
public void pauseVideoTransfer()
public void resumeVideoTransfer()
public void setAdaptiveVideoFlag(boolean enable)
enable
- public int getVoiceInputLevel()
public java.util.List<EMMessage> getMessagesByMsgType(EMMessage.Type messageType, EMMessage.ChatType chatType, java.lang.String userName, java.lang.String startMessageId, int num)
messageType
- 消息的类型chatType
- 聊天类型userName
- 用户id(群组id)strtMessageId
- 消息id,分页加载起始位置,第一次加载没有messageid可置为空num
- 分页加载的消息数目public long getTotalMessageCountByMsgType(EMMessage.Type messageType, EMMessage.ChatType chatType, java.lang.String userName)
messageType
- 消息的类型chatType
- 聊天类型userName
- 用户id(群组id)public void onEnterForeground()
public void disconnect()
public void reconnect()
Copyright © 2014 EaseMob.com. All Rights Reserved.