Browse SDKs · Android
Platform
SDKsAndroid

Get the blacklist

Retrieve the complete list of blocked users for the authenticated account using getBlacklist().

Copy

Retrieve the full list of users blocked by the authenticated account. This is typically used in privacy settings to manage blocked accounts or on user profile cards to render a "Blocked" state.

Code example

OpenIMClient.getInstance().friendshipManager.getBlacklist(
    new OnBase<List<UserInfo>>() {
        @Override
        public void onSuccess(List<UserInfo> users) {
            // Update blocked users list UI using users
        }

        @Override
        public void onError(int code, String error) {
            // Handle error
        }
    }
);

Parameters

ParameterTypeRequiredDescription
baseOnBase<List<UserInfo>>YesCallback delivering the asynchronous operation result.

Return value

The successful callback returns a List<UserInfo>. If no users are blocked, an empty list is returned. Deduplicate and cache items using userID as the unique key.

Access BlacklistInfo on each UserInfo object via the blackInfo property:

FieldDescription
userIDUser ID of the blocked user.
nicknameDisplay nickname of the blocked user.
faceURLAvatar URL of the blocked user.
genderGender indicator of the blocked user.
operatorUserIDUser ID of the operator who executed the block.
createTimeUnix timestamp when the user was added to the blocklist.
addSourceChannel or origin of the block operation.
exCustom blocklist extension metadata.

When users are added to or removed from the blocklist, the SDK dispatches events via OnFriendshipListener; see Add to blacklist and Remove from blacklist.