Browse SDKs · Android
SDKsAndroid

Get the blacklist

Use getBlacklist() to retrieve the current user blacklist.

Copy

The blacklist records users blocked by the current account. Use it for a blacklist settings screen, relationship state on a profile card, or to limit a chat entry point. Blacklist management and group member management are separate capabilities; use Group APIs to mute, remove, or change the role of a group member.

Get the blacklist

After SDK initialization and login, call getBlacklist() to retrieve the full blacklist for the signed-in account. An empty list means no users are blocked.

OpenIMClient.getInstance().friendshipManager.getBlacklist(
    new OnBase<List<UserInfo>>() {
        @Override
        public void onSuccess(List<UserInfo> users) {
            blacklistStore.replace(users);
        }

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

The callback returns List<UserInfo>; call UserInfo.getBlackInfo() to retrieve the blacklist relationship object.

Blacklist record fields

Common BlacklistInfo fields are:

FieldDescription
userIDTarget user ID blocked by the current user and the stable list key.
nicknameTarget user nickname snapshot.
faceURLTarget user avatar URL.
genderTarget user gender value.
operatorUserIDUser ID that performed the block operation.
createTimeBlacklist relationship creation time.
addSourceSource that added the blacklist relationship.
exBlacklist relationship extension string.

When the screen also needs friend remarks or the latest public profile, separately merge FriendInfo or PublicUserInfo by userID. Do not treat blacklist fields as friend profile data.

Merge blacklist state by userID. This query does not trigger blacklist added or deleted callbacks. Replace the local snapshot on initial load, after reconnecting, or after an explicit refresh; incremental changes are owned by the Block a user and Unblock a user listener pages.