Browse SDKs · Android
SDKsAndroid

Search friends

Use searchFriends() to search the current user friend list.

Copy
OpenIMClient.getInstance().friendshipManager.searchFriends(
    new OnBase<List<FriendInfo>>() {
        @Override
        public void onSuccess(List<FriendInfo> results) {
            showFriendSearchResults(results);
        }

        @Override
        public void onError(int code, String error) {
            recordFriendSearchFailure(code, error);
        }
    },
    Collections.singletonList(keyword.trim()),
    true,
    true,
    true
);

Pass one non-empty value in keywordList. The three Boolean arguments select matching by user ID, nickname, and friend remark. Enable at least one field. To search multiple fields, enable the corresponding flags; the API does not treat multiple keywords as independent search conditions.

The callback returns List<FriendInfo>. Search results belong to the current search view and should not replace the full friend snapshot. This query does not trigger friendship callbacks.