SDKsAndroid
Search friends
Search friends locally by keywords matching user ID, nickname, and remark alias.
Perform local fuzzy searches across the authenticated account's friend database, matching by user ID, nickname, and remark name.
Code example
OpenIMClient.getInstance().friendshipManager.searchFriends(
new OnBase<List<FriendInfo>>() {
@Override
public void onSuccess(List<FriendInfo> results) {
// Display search results using results
}
@Override
public void onError(int code, String error) {
// Handle error
}
},
Collections.singletonList(keyword.trim()),
true,
true,
true
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<List<FriendInfo>> | Yes | Callback delivering the asynchronous operation result. |
keywordList | List<String> | Yes | List of search keywords, typically containing a single non-empty query string. |
isSearchUserID | boolean | Yes | Whether to search against user IDs. |
isSearchNickname | boolean | Yes | Whether to search against nicknames. |
isSearchRemark | boolean | Yes | Whether to search against remark names. |
At least one search toggle must be set to true.
Return value
The successful callback returns matching records as List<FriendInfo>. Deduplicate and render results using userID as the primary key. If no matching friends are found, an empty list is returned.
Was this page helpful?