Chat SDK for Android v1.3.2
agora java chat SDK
 
Loading...
Searching...
No Matches
Chat SDK for Android

Agora Chat is a highly reliable global communication platform where your users can chat one-to-one, in groups or in chat rooms, communicating with text messages and sharing images, audios, videos, files, emojis, and locations. The Agora Chat SDK provides the following classes:

  • The ChatClient class is the entry of the chat SDK. It provides methods to allow you to log in to and log out of the chat app and manage the connection between the SDK and the chat server.
  • The ChatManager class provides methods to allow you to send and receive messages, manage conversations (including loading and deleting conversations), and download attachments.
  • The ChatMessage class defines message attributes.
  • The Conversation class provides methods for conversation management.
  • The ContactManager class provides methods for chat contact management such as adding, retrieving, modifying, and deleting contacts.
  • The GroupManager class provides methods for group management, like group creation and destruction and member management.
  • The ChatRoomManager class provides methods for chat room management, like joining and leaving the chat room and retrieving the chat room list, and manages member privileges.
  • The PresenceManager class provides methods for you to set message push configuration options.
  • The ChatThreadManager class provides methods for message thread management, including thread creation, destruction, and member management.
  • The PushManager class provides methods to allow you to manage offline push services.
  • The UserInfoManager class provides methods for user attribute management, including getting and updating user attributes.

During API calls, the SDK may return error codes and warning codes. See Error Codes and Warning Codes.

Chat Client

Method Description
init Initializes the SDK.
loginWithToken Logs in to the chat server with the user ID and Agora token.
renewToken Renews the Agora token.
logout Logs out of the chat server.
getCurrentUser Gets the user ID of the current logged-in user.
isLoggedInBefore Checks whether the user has logged in before.
isConnected Checks whether the SDK is connected to the Chat server.
isLoggedIn Checks whether the user has logged in to the Chat app.
setDebugMode Sets whether to output the debug information.
isSdkInited Checks whether the SDK is initialized.
addConnectionListener Adds a connection status listener.
addLogListener Adds the log callback listener of SDK.
groupManager Gets the GroupManager class.
pushManager Gets the PushManager class.
chatroomManager Gets the ChatRoomManager class.
chatManager Gets the ChatManager class.
userInfoManager Gets the UserInfoManager class.
contactManager Gets the ContactManager class.
presenceManager Gets the PresenceManager class.
chatThreadManager Gets the ChatThreadManager class.
Event Description
onConnected Occurs when the SDK connects to the chat server successfully.
onDisconnected Occurs when the SDK disconnects from the chat server.
onTokenExpired Occurs when the token has expired.
onTokenWillExpire Occurs when the token is about to expire.
onLogout Occurs when a user is forced to log out of the SDK.
onLog Occurs when a log is generated.

Chat manager

Method Description
sendMessage Sends a message.
ackConversationRead Sends the conversation read receipt to the server.
ackMessageRead Sends the read receipt for a message to the server.
ackGroupMessageRead Sends the read receipt for a group message to the server.
getConversation Gets the conversation object by conversation ID.
markAllConversationsAsRead Marks all conversations as read.
saveMessage Saves the message to the memory and local database.
updateMessage Updates the local message.
downloadAttachment Downloads the message attachment.
downloadThumbnail Downloads the message thumbnail.
importMessages Imports messages to the local database.
getAllConversations Gets all local conversations.
asyncFetchConversationsFromServer Gets the conversation list from the server.
asyncFetchConversationsFromServer Gets the conversation list from the server with pagination.
deleteConversation Deletes a conversation and its local messages from the local database.
deleteConversationFromServer Deletes the specified conversation and its historical messages from the server.
fetchGroupReadAcks Uses the pagination to get read receipts for a group message from the server.
searchMsgFromDB Retrieves messages of a certain type in the conversation from the local database.
deleteMessagesBeforeTimestamp Deletes local historical messages with a Unix timestamp before a specified one.
asyncReportMessage Reports an inappropriate message.
fetchSupportLanguages Gets all languages supported by the translation service.
translateMessage Translates a text message.
asyncAddReaction Adds a Reaction.
asyncRemoveReaction Deletes a Reaction.
asyncGetReactionList Gets the list of Reactions.
asyncGetReactionDetail Gets the Reaction details.
addMessageListener Adds the message listener.
addConversationListener Adds the conversation listener.
Event Description
onMessageReceived Occurs when a message is received.
onCmdMessageReceived Occurs when a command message is received.
onMessageRead Occurs when a read receipt is received for a message.
onGroupMessageRead Occurs when a read receipt is received for a group message.
onReadAckForGroupMessageUpdated Occurs when the update for the group message read status is received.
onMessageDelivered Occurs when a delivery receipt is received.
onMessageRecalled Occurs when a received message is recalled.
onReactionChanged Occurs when a message Reaction changed.
onConversationUpdate Occurs when the conversation is updated.
onConversationRead Occurs when the conversation read receipt is received.

Messages

Method Description
conversationId The conversation ID, which depends on the conversation type.
getUnreadMsgCount Gets the number of unread messages in the conversation.
markAllMessagesAsRead Marks all unread messages as read.
getAllMsgCount Gets the number of all unread messages in the conversation in the local database.
isChatThread Checks whether the current conversation is a thread conversation.
loadMoreMsgFromDB Loads the messages from the local database, starting from a specific message ID.
getMessage Gets the message with message ID.
markMessageAsRead Marks a message as read.
getAllMessages Gets all messages of the conversation in the local memory.
removeMessage Deletes a message in the local database.
getLastMessage Gets the latest message in the conversation.
getLatestMessageFromOthers Gets the latest received message in the conversation.
clear Deletes all the messages in the conversation.
clearAllMessages Deletes all the messages in the conversation from the memory and local database.
setExtField Sets the extension field of the conversation.
getExtField Gets the extension field of the conversation.
insertMessage Inserts a message to the conversation in the local database。.
appendMessage Inserts a message to the end of the conversation in the local database.
updateMessage Updates a message in the local database.
status Gets the message sending or reception status.
setStatus Sets the message sending or reception status.
getType Gets the chat message type.
getBody Gets the message body.
getMsgTime Gets the Unix timestamp when the server receives the message.
setMsgTime Sets the Unix timestamp when the server receives the message.
localTime Gets the local timestamp of the message.
setLocalTime Sets the local timestamp of the message.
setIsChatThreadMessage Sets whether the message is a threaded message.
isChatThreadMessage Gets whether the message is a threaded message.
getChatThread Gets the overview of the message thread.
createSendMessage Creates a message instance for sending.
createReceiveMessage Creates a received message instance.
createTextSendMessage Creates a text message for sending.
createVoiceSendMessage Creates a voice message for sending.
createImageSendMessage Creates an image message for sending.
createVideoSendMessage Creates a video message for sending.
createLocationSendMessage Creates a location message for sending.
createFileSendMessage Creates a file message for sending.
setBody (Recommended) Sets the message body.
addBody Adds a message body.
getFrom Gets the user ID of the message sender.
setFrom Sets the user ID of the message sender.
getRecaller Gets the ID of the user that recalls the message.
setTo Sets the user ID of the message recipient.
getTo Gets the user ID of the message recipient.
getMsgId Gets the message ID.
setMsgId Sets the local message ID.
setMessageStatusCallback Sets the message status change callback.
setAttribute Sets a message extension attribute of the String type.
getStringAttribute Gets a message extension attribute of the String type.
getChatType Gets the chat type.
setChatType Sets the chat type.
isAcked Gets whether the message is read.
setAcked Sets whether the message is read.
isDelivered Gets whether the message is successfully delivered.
setDelivered Sets whether the message is successfully delivered.
isUnread Checks whether the message is unread.
setUnread Sets whether the message is unread.
isListened Gets whether the voice message is listened.
setListened Sets whether the voice message is listened.
getUserName Gets the user ID of the other party:.
direct Gets the message direction.
setDirection Sets the message direction.
conversationId Gets the conversation ID.
ext Gets all message extension fields.
getMessageReaction Gets the list of Reactions.
isOnlineState Checks whether the message gets delivered to an online user.
setPriority Set message priority chatroom message priority.
Event Description
onSuccess Occurs when the method succeeds.
onError Occurs when an error occurs. See Error.
onProgress Occurs when the progress updates.

Contacts

Method Description
asyncAddContact Adds a new contact.
deleteContact Deletes a contact.
asyncGetAllContactsFromServer Gets all contacts from the server.
addUserToBlackList Adds a user to block list.
saveBlackList Uploads the block list to server.
removeUserFromBlackList Removes the contact from the block list.
getBlackListUsernames Gets the local block list.
asyncGetBlackListFromServer Gets the block list from the server.
declineInvitation Declines a friend invitation.
getContactsFromLocal Gets the contact list from the local database.
asyncGetSelfIdsOnOtherPlatform Gets the unique self-ID list of the current user on the other devices.
setContactListener Registers a new contact listener.
Event Description
onContactAdded Occurs when a user is added as a contact.
onContactDeleted Occurs when a user is removed from the contact list.
onContactInvited Occurs when a user receives a friend request.
onFriendRequestAccepted Occurs when a friend request is approved.
onFriendRequestDeclined Occurs when a friend request is declined.

Chat Group

Method Description
asyncCreateGroup Creates a group instance.
asyncDestroyGroup Destroys the group instance.
asyncLeaveGroup Leaves a group.
asyncJoinGroup Joins a public group.
asyncAddUsersToGroup Adds users to the group.
asyncRemoveUsersFromGroup Removes members from the group.
asyncGetGroupFromServer Gets group information from the server.
asyncGetJoinedGroupsFromServer Gets all groups of the current user from the server with pagination.
asyncGetPublicGroupsFromServer Gets public groups from the server with pagination.
asyncChangeGroupName Changes the group name.
asyncChangeGroupDescription Changes the group description.
asyncAcceptInvitation Accepts a group invitation.
asyncDeclineInvitation Declines a group invitation.
asyncAcceptApplication Approves a group request.
asyncDeclineApplication Declines a group request.
asyncInviteUser Invites users to join a group.
asyncApplyJoinToGroup Requests to join a group.
asyncBlockGroupMessage Blocks group messages.
asyncUnblockGroupMessage Unblocks group messages.
asyncBlockUsers Adds the user to the group block list.
asyncUnblockUsers Removes users from the group block list.
asyncGetBlockedUsers Gets the group block list with pagination.
asyncFetchGroupMembers Gets the member list of a group with pagination.
asyncChangeOwner Transfers the group ownership.
asyncAddGroupAdmin Adds a group admin.
asyncRemoveGroupAdmin Removes a group admin.
asyncMuteGroupMembers Mutes group members.
asyncUnMuteGroupMembers Unmutes group members.
muteAllMembers Mutes all members.
unmuteAllMembers Unmutes all members.
asyncFetchGroupMuteList Gets the mute list of the group from the server.
asyncFetchGroupBlackList Gets the block list of group from the server with pagination.
addToGroupWhiteList Adds members to the allow list.
removeFromGroupWhiteList Removes members from the allow list.
fetchGroupWhiteList Gets the allow list of the group from the server.
asyncUpdateGroupAnnouncement Updates the group announcement.
asyncFetchGroupAnnouncement Gets the group announcement from the server.
asyncUploadGroupSharedFile Uploads the shared file to the group.
asyncFetchGroupSharedFileList Gets the shared file list from the server.
asyncDeleteGroupSharedFile Removes the shared file of the group.
asyncDownloadGroupSharedFile Downloads the shared file of the group.
getAllGroups Gets all groups of the current user (from the memory).
getGroup Gets the group instance from the memory by group ID.
loadAllGroups Loads all local groups from the database.
addGroupChangeListener Registers a group change listener.
Event Description
onInvitationReceived Occurs when the user receives a group invitation.
onRequestToJoinReceived Occurs when the group owner or administrator receives a group request from a user.
onRequestToJoinAccepted Occurs when a group request is accepted.
onRequestToJoinDeclined Occurs when a group request is declined.
onInvitationAccepted Occurs when a group invitation is accepted.
onInvitationDeclined Occurs when a group invitation is declined.
onUserRemoved Occurs when the current user is removed from the group by the group admin.
onGroupDestroyed Occurs when a group is destroyed.
onAutoAcceptInvitationFromGroup Occurs when the group invitation is accepted automatically.
onMuteListAdded Occurs when one or more group members are muted.
onMuteListRemoved Occurs when one or more group members are unmuted.
onWhiteListAdded Occurs when one or more group members are added to the allowlist.
onWhiteListRemoved Occurs when one or more members are removed from the allowlist.
onAllMemberMuteStateChanged Occurs when all group members are muted or unmuted.
onAdminAdded Occurs when a member is set as an admin.
onAdminRemoved Occurs when a member's admin privileges are removed.
onOwnerChanged Occurs when the group ownership is transferred.
onMemberJoined Occurs when a member joins a group.
onMemberExited Occurs when a member proactively leaves the group.
onAnnouncementChanged Occurs when the announcement is updated.
onSharedFileAdded Occurs when a shared file is added to a group.
onSharedFileDeleted Occurs when a shared file is removed from a group.
onSpecificationChanged Occurs when the group details are updated.
onStateChanged Occurs when the group is enabled or disabled.

Chat Room

Method Description
asyncCreateChatRoom Creates a chat room.
asyncDestroyChatRoom Destroys a chat room.
joinChatRoom Joins a chat room.
leaveChatRoom Exits a chat room.
fetchPublicChatRoomsFromServer Gets chat room data from the server with pagination.
asyncFetchPublicChatRoomsFromServer Gets chat room data from the server with pagination.
fetchChatRoomFromServer Gets details of a chat room from the server.
asyncChangeChatRoomSubject Changes the chat room name.
asyncChangeChatroomDescription Modifies the chat room description.
asyncFetchChatRoomMembers Gets the chat room member list.
asyncMuteChatRoomMembers Mutes members in a chat room.
asyncUnMuteChatRoomMembers Unmutes members in a chat room.
asyncAddChatRoomAdmin Adds a chat room admin.
asyncRemoveChatRoomAdmin Removes the administrative privilege of a chat room admin.
asyncFetchChatRoomMuteList Gets the list of muted chat room members from the server.
asyncRemoveChatRoomMembers Removes members from a chat room.
asyncBlockChatroomMembers Adds members to the block list of the chat room.
asyncUnBlockChatRoomMembers Removes members from the block list of the chat room.
asyncFetchChatRoomBlackList Gets the chat room block list with pagination.
addToChatRoomWhiteList Adds members to the allow list of the chat room.
removeFromChatRoomWhiteList Removes members from the chat room block list.
fetchChatRoomWhiteList Gets the chat room allow list from the server.
muteAllMembers Mutes all members.
unmuteAllMembers Unmutes all members.
asyncUpdateChatRoomAnnouncement Updates the chat room announcement.
asyncFetchChatRoomAnnouncement Gets the chat room announcement from the server.
asyncSetChatroomAttributes Adds custom chat room attributes.
asyncSetChatroomAttribute Sets a custom chat room attribute.
asyncSetChatroomAttributesForced Sets custom chat room attributes forcibly.
asyncSetChatroomAttributeForced Sets a custom chat room attribute forcibly.
asyncFetchChatroomAttributesFromServer Gets the list of custom chat room attributes based on the attribute key list.
asyncFetchChatRoomAllAttributesFromServer Gets all the custom attributes of a chat room.
asyncRemoveChatRoomAttributesFromServer Removes custom chat room attributes by the attribute key list.
asyncRemoveChatRoomAttributeFromServer Removes a custom chat room attribute.
asyncRemoveChatRoomAttributesFromServerForced Removes custom chat room attributes forcibly.
asyncRemoveChatRoomAttributeFromServerForced Removes a custom chat room attribute forcibly.
addChatRoomChangeListener Adds a chat room event listener.
Event Description
onChatRoomDestroyed Occurs when the chat room is destroyed.
onMemberJoined Occurs when a member joins the chat room.
onMemberExited Occurs when a member exits the chat room.
onRemovedFromChatRoom Occurs when a member is removed from a chat room.
onMuteListAdded Occurs when the chat room member(s) is/are added to the mute list.
onMuteListRemoved Occurs when the chat room member(s) is/are removed from the mute list.
onWhiteListAdded Occurs when the chat room member(s) is/are added to the allow list.
onWhiteListRemoved Occurs when the chat room member(s) is/are removed from the allow list.
onAllMemberMuteStateChanged Occurs when all members in the chat room are muted or unmuted.
onAdminAdded Occurs when a chat room member is set as an admin.
onAdminRemoved Occurs when the chat room member(s) is/are removed from the admin list.
onOwnerChanged Occurs when the chat room owner is changed.
onAnnouncementChanged Occurs when the chat room announcement changes.
onSpecificationChanged Occurs when the chat room specifications changes.
onAttributesUpdate Occurs when the custom chat room attribute(s) is/are updated.
onAttributesRemoved Occurs when the custom chat room attribute(s) is/are removed.

Presence

Method Description
publishPresence Publishes a custom presence state.
subscribePresences Subscribes to a user's presence states.
unsubscribePresences Unsubscribes from a user's presence states.
fetchSubscribedMembers Uses pagination to get a list of users whose presence states you have subscribed to.
fetchPresenceStatus Gets the current presence state of users.
addListener Adds a listener.
Event Description
onPresenceUpdated Occurs when the presence state of the user subscribed is updated.

Threading

Method Description
createChatThread Creates a message thread.
joinChatThread Joins a message thread.
destroyChatThread Destroys the message thread.
leaveChatThread Leaves a message thread.
getChatThreadFromServer Gets the details of the message thread from the server.
updateChatThreadName Changes the name of the message thread.
removeMemberFromChatThread Removes a member from the message thread.
getChatThreadMembers Gets a list of members in the message thread with pagination.
getJoinedChatThreadsFromServer Uses the pagination to get the list of message threads that the current user has joined.
getJoinedChatThreadsFromServer Uses the pagination to get the list of message threads that the current user has joined in the specified group.
getChatThreadsFromServer Uses the pagination to get the list of message threads in the specified group.
getChatThreadLatestMessage Gets the last reply in the specified message threads from the server.
addChatThreadChangeListener Adds the message thread event listener, which listens for message thread changes, such as the message thread creation and destruction.
Event Description
onChatThreadCreated Occurs when a message thread is created.
onChatThreadUpdated Occurs when a message thread is updated.
onChatThreadDestroyed Occurs when a message thread is destroyed.
onChatThreadUserRemoved Occurs when the current user is removed from the message thread by the group owner or a group admin to which the message thread belongs.

Offline push

Method Description
getPushConfigs Gets the push configurations from the memory.
getPushConfigsFromServer Gets the push configurations from the server.
asyncUpdatePushNickname Updates the push display nickname of the current user.
setSilentModeForConversation Sets the DND of the conversation.
clearRemindTypeForConversation Clears the setting of offline push notification type for the conversation.
getSilentModeForConversation Gets the DND setting of the conversation.
setSilentModeForAll Sets the DND settings for the current login user.
getSilentModeForAll Gets the DND settings of the current logged-in user.
getSilentModeForConversations Obtains the DND Settings of specified conversations in batches.
bindDeviceToken Binds a device token to the Chat server.

User Attributes

Method Description
updateOwnInfo Modifies information of the current user.
updateOwnInfoByAttribute Modifies attributes of the current user.
fetchUserInfoByUserId Gets user information by user ID.
fetchUserInfoByAttribute Gets user information by user ID and user attributes.