Chat SDK for Android v1.3.1
agora java chat SDK
Public Member Functions | List of all members
io.agora.chat.ContactManager Class Reference

Public Member Functions

void addContact (String username, String reason) throws ChatException
 
void asyncAddContact (final String username, final String reason, final CallBack callback)
 
void deleteContact (String username) throws ChatException
 
void deleteContact (String username, boolean keepConversation) throws ChatException
 
void asyncDeleteContact (final String username, final CallBack callback)
 
List< String > getAllContactsFromServer () throws ChatException
 
void asyncGetAllContactsFromServer (final ValueCallBack< List< String > > callback)
 
void setContactListener (ContactListener contactListener)
 
void removeContactListener (ContactListener contactListener)
 
void addUserToBlackList (String username, boolean both) throws ChatException
 
void asyncAddUserToBlackList (final String username, final boolean both, final CallBack callback)
 
void saveBlackList (List< String > blackList) throws ChatException
 
void asyncSaveBlackList (final List< String > blackList, final CallBack callback)
 
void removeUserFromBlackList (String username) throws ChatException
 
void asyncRemoveUserFromBlackList (final String username, final CallBack callback)
 
List< String > getBlackListUsernames ()
 
List< String > getBlackListFromServer () throws ChatException
 
void asyncGetBlackListFromServer (final ValueCallBack< List< String > > callback)
 
void acceptInvitation (String username) throws ChatException
 
void asyncAcceptInvitation (final String username, final CallBack callback)
 
void declineInvitation (String username) throws ChatException
 
void asyncDeclineInvitation (final String username, final CallBack callback)
 
List< String > getContactsFromLocal () throws ChatException
 
List< String > getSelfIdsOnOtherPlatform () throws ChatException
 
void asyncGetSelfIdsOnOtherPlatform (final ValueCallBack< List< String > > callback)
 
void asyncSetContactRemark (@NonNull String username, @NonNull String remark, CallBack callback)
 
Contact fetchContactFromLocal (String username) throws ChatException
 
void asyncFetchAllContactsFromLocal (ValueCallBack< List< Contact > > callback)
 
void asyncFetchAllContactsFromServer (ValueCallBack< List< Contact > > callback)
 
void asyncFetchAllContactsFromServer (int limit, String cursor, ValueCallBack< CursorResult< Contact > > callback)
 

Detailed Description

The ContactManager is used to record, query, and modify contacts.

Member Function Documentation

◆ acceptInvitation()

void io.agora.chat.ContactManager.acceptInvitation ( String  username) throws ChatException

Accepts a friend invitation。

This is a synchronous method and blocks the current thread.

For the asynchronous method, see asyncAcceptInvitation(String, CallBack).

Parameters
usernameThe user who initiates the friend request.

◆ addContact()

void io.agora.chat.ContactManager.addContact ( String  username,
String  reason 
) throws ChatException

Adds a new contact.

This is a synchronous method and blocks the current thread.

Reference: For the asynchronous method, see asyncAddContact(String, String, CallBack).

Parameters
usernameThe user ID of the contact to add.
reason(optional) The invitation message. Set the parameter as null or "" if you want to ignore this parameter.
Exceptions
ChatExceptionA description of the issue that caused this exception.

◆ addUserToBlackList()

void io.agora.chat.ContactManager.addUserToBlackList ( String  username,
boolean  both 
) throws ChatException

Adds a user to the block list.

You can send messages to the users on the block list, but cannot receive message from them.

For the asynchronous method, see asyncAddUserToBlackList(String, boolean, CallBack).

You can add multiple users in bulk by calling saveBlackList(List).

This is a synchronous method and blocks the current thread.

Parameters
usernameThe user to add to the block list.
bothThis parameter is deprecated.
Exceptions
ChatExceptionA description of the issue that caused the exception.

◆ asyncAcceptInvitation()

void io.agora.chat.ContactManager.asyncAcceptInvitation ( final String  username,
final CallBack  callback 
)

Accepts a friend invitation.

This an asynchronous method.

For the synchronous method, see acceptInvitation(String).

Parameters
usernameThe user who initiates the friend request.
callbackThe SDK returns Success if the call succeeds, but the description of the cause if the call fails.

◆ asyncAddContact()

void io.agora.chat.ContactManager.asyncAddContact ( final String  username,
final String  reason,
final CallBack  callback 
)

Adds a new contact.

This is an asynchronous method.

Reference: For the synchronous method, see addContact(String, String)

Parameters
usernameThe user ID of the contact to add.
reason(optional) The invitation message. Set the parameter as null or "" if you want to ignore this parameter.
callbackThe result of the method, which contains the error information if the method fails.

◆ asyncAddUserToBlackList()

void io.agora.chat.ContactManager.asyncAddUserToBlackList ( final String  username,
final boolean  both,
final CallBack  callback 
)

Adds a user to the block list.

You can send messages to the users on the block list, but cannot receive message from them.

For the synchronous method, see addUserToBlackList(String, boolean).

You can add multiple users in bulk by calling asyncSaveBlackList(List, CallBack).

Parameters
usernameThe user to add to the block list.
bothThis parameter is deprecated.
callbackThe callback completion.
  • Success: The user is successfully added to the block list.
  • Error: The user fails to be added to the block list. The reason for the failure will be returned.

◆ asyncDeclineInvitation()

void io.agora.chat.ContactManager.asyncDeclineInvitation ( final String  username,
final CallBack  callback 
)

Declines a friend invitation.

This an asynchronous method.

For the synchronous method, see declineInvitation(String).

Parameters
usernameThe user who initiates the friend request.
callbackThe SDK returns Success if the call succeeds, but the description of the cause if the call fails.

◆ asyncDeleteContact()

void io.agora.chat.ContactManager.asyncDeleteContact ( final String  username,
final CallBack  callback 
)

Deletes a contact.

This is an asynchronous method.

For the synchronous method, see deleteContact(String).

Parameters
usernameThe user ID of the contact to delete.
callbackThe SDK returns Success if the call succeeds, but the description of the cause if the call fails.

◆ asyncFetchAllContactsFromLocal()

void io.agora.chat.ContactManager.asyncFetchAllContactsFromLocal ( ValueCallBack< List< Contact > >  callback)

Gets all contacts from the local database.

Parameters
callbackThe SDK returns Success plus all contacts if the call succeeds, but the description of the cause if the call fails.

◆ asyncFetchAllContactsFromServer() [1/2]

void io.agora.chat.ContactManager.asyncFetchAllContactsFromServer ( int  limit,
String  cursor,
ValueCallBack< CursorResult< Contact > >  callback 
)

Gets all contacts from the server with pagination.

Parameters
limitThe number of contacts that you expect to get on each page.The value ranges from [1-50].
cursorThe cursor position from which to start getting data. Pass null or "" at the first call of this method to get the contacts that are added most recently.
callbackCursorResult, including the cursor for the next query and the contact list object. For the last page, the cursor is an empty string.

◆ asyncFetchAllContactsFromServer() [2/2]

void io.agora.chat.ContactManager.asyncFetchAllContactsFromServer ( ValueCallBack< List< Contact > >  callback)

Gets all contacts from the server.

Parameters
callbackThe SDK returns Success plus all contacts if the call succeeds, but the description of the cause if the call fails.

◆ asyncGetAllContactsFromServer()

void io.agora.chat.ContactManager.asyncGetAllContactsFromServer ( final ValueCallBack< List< String > >  callback)

Get all contacts from the server.

This is a synchronous method see getAllContactsFromServer().

Parameters
callbackThe SDK returns the contact list if the call succeeds, but the description of the cause if the call fails.

◆ asyncGetBlackListFromServer()

void io.agora.chat.ContactManager.asyncGetBlackListFromServer ( final ValueCallBack< List< String > >  callback)

Gets the block list from the server.

For the synchronous method, see getBlackListFromServer().

Parameters
callbackThe SDK returns the block list if the call succeed, but the description of the cause if the call fails.

◆ asyncGetSelfIdsOnOtherPlatform()

void io.agora.chat.ContactManager.asyncGetSelfIdsOnOtherPlatform ( final ValueCallBack< List< String > >  callback)

Gets the unique IDs of the current user on the other devices. The ID is in the format of user ID + "/" + resource (device ID).

This is an asynchronous method.

For the synchronous method, see getSelfIdsOnOtherPlatform().

Parameters
callbackThe completion callback.
  • The SDK returns the unique IDs of the current user on the other devices if the method succeeds.
  • The SDK returns the description of the cause of the error if the method fails.

◆ asyncRemoveUserFromBlackList()

void io.agora.chat.ContactManager.asyncRemoveUserFromBlackList ( final String  username,
final CallBack  callback 
)

Removes a contact from the block list.

For the synchronous method, see removeUserFromBlackList(String).

Parameters
usernameThe user to be removed from the block list.
callbackThe completion callback.
  • Success: The user is successfully removed from the block list.
  • Error: The user fails to be removed from the block list. The reason for the failure will be returned.

◆ asyncSaveBlackList()

void io.agora.chat.ContactManager.asyncSaveBlackList ( final List< String >  blackList,
final CallBack  callback 
)

Uploads the block list to the server.

For the synchronous method, see saveBlackList(List).

Parameters
blackListThe block list to upload to the server.
callbackThe completion callback.
  • Success: The block list is uploaded to the server.
  • Error: The block list fails to be uploaded to the server. The reason for the failure will be returned.

◆ asyncSetContactRemark()

void io.agora.chat.ContactManager.asyncSetContactRemark ( @NonNull String  username,
@NonNull String  remark,
CallBack  callback 
)

Sets remarks of a contact.

Parameters
usernameThe user ID of the contact.
remarkThe remarks of the contact.
callbackThe completion callback. The SDK returns Success if the call succeeds, but the description of the cause if the call fails.

◆ declineInvitation()

void io.agora.chat.ContactManager.declineInvitation ( String  username) throws ChatException

Declines a friend invitation.

This is a synchronous method and blocks the current thread.

For the asynchronous method, see asyncDeclineInvitation(String, CallBack).

Parameters
usernameThe user who initiates the invitation.

◆ deleteContact() [1/2]

void io.agora.chat.ContactManager.deleteContact ( String  username) throws ChatException

Deletes a contact and all the related conversations.

This is a synchronous method and blocks the current thread.

Parameters
usernameThe user ID of the contact delete.
Exceptions
ChatExceptionA description of the issue that caused the exception.

◆ deleteContact() [2/2]

void io.agora.chat.ContactManager.deleteContact ( String  username,
boolean  keepConversation 
) throws ChatException

Deletes a contact.

This is a synchronous method and blocks the current thread.

Parameters
usernameThe user ID.
keepConversationWhether to keep the related conversation and messages.
  • true: The contact is deleted, while the related conversation and messages are retained.
  • false: The related conversation and messages are deleted with the contact.
Exceptions
ChatExceptionA description of the issue that caused the exception.

◆ fetchContactFromLocal()

Contact io.agora.chat.ContactManager.fetchContactFromLocal ( String  username) throws ChatException

Gets a contact from the local database.

Parameters
usernameThe user ID of the contact.
Exceptions
ChatExceptionA description of the issue that caused this call to fail.

◆ getAllContactsFromServer()

List< String > io.agora.chat.ContactManager.getAllContactsFromServer ( ) throws ChatException

Get all contacts from the server.

This is a synchronous method and blocks the current thread.

For the asynchronous method, see asyncGetAllContactsFromServer(ValueCallBack).

Returns
The list of contacts.
Exceptions
ChatExceptionA description of the exception.

◆ getBlackListFromServer()

List< String > io.agora.chat.ContactManager.getBlackListFromServer ( ) throws ChatException

Gets the block list from the server.

For the asynchronous method, see asyncGetBlackListFromServer(ValueCallBack).

This is a synchronous method and blocks the current thread.

Returns
The SDK returns the block list if the method succeeds.
Exceptions
ChatExceptionA description of the issue that caused the exception.

◆ getBlackListUsernames()

List< String > io.agora.chat.ContactManager.getBlackListUsernames ( )

Gets the local block list.

Returns
The block list.

◆ getContactsFromLocal()

List< String > io.agora.chat.ContactManager.getContactsFromLocal ( ) throws ChatException

Gets the contact list from the local database.

Returns
The contact list.
Exceptions
ChatExceptionA description of the issue that caused the exception.

◆ getSelfIdsOnOtherPlatform()

List< String > io.agora.chat.ContactManager.getSelfIdsOnOtherPlatform ( ) throws ChatException

Gets the unique IDs of the current user on the other devices. The ID is in the format of user ID + "/" + resource (device ID).

This is a synchronous method and blocks the current thread.

For the asynchronous method, see asyncGetSelfIdsOnOtherPlatform(ValueCallBack).

Returns
The SDK returns the unique IDs of the current user on the other devices if the method succeeds.
Exceptions
ChatExceptionA description of the issue that caused this call to fail.

◆ removeContactListener()

void io.agora.chat.ContactManager.removeContactListener ( ContactListener  contactListener)

Removes a contact listener.

You can add a contact listener by calling setContactListener(ContactListener).

◆ removeUserFromBlackList()

void io.agora.chat.ContactManager.removeUserFromBlackList ( String  username) throws ChatException

Removes the contact from the block list.

For the asynchronous method, see asyncRemoveUserFromBlackList(String, CallBack).

This is a synchronous method and blocks the current thread.

Parameters
usernameThe user to be removed from the block list.
Exceptions
ChatExceptionA description of the exception.

◆ saveBlackList()

void io.agora.chat.ContactManager.saveBlackList ( List< String >  blackList) throws ChatException

Uploads the block list to the server.

This is a synchronous method and blocks the current thread.

For the asynchronous method, see asyncSaveBlackList(List, CallBack).

Parameters
blackListThe block list to upload to the server.

◆ setContactListener()

void io.agora.chat.ContactManager.setContactListener ( ContactListener  contactListener)

Registers a new contact listener.

You can call removeContactListener(ContactListener) to remove the listener.

Parameters
contactListenerThe contact listener to register.

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