Browse SDKs · Android
Platform
SDKsAndroid

Search groups

Search local group records by keywords matching group ID or group name using searchGroups().

Copy

Search local group records by keywords matching group IDs or group names. Configure individual boolean toggles to enable or disable search targets.

Code example

List<String> keywordList = Collections.singletonList("Engineering");
boolean isSearchGroupID = true;
boolean isSearchGroupName = true;

OpenIMClient.getInstance().groupManager.searchGroups(
    new OnBase<List<GroupInfo>>() {
        @Override
        public void onSuccess(List<GroupInfo> groups) {
            // groups contains matching group records
        }

        @Override
        public void onError(int code, String error) {
            // Handle search failure
        }
    },
    keywordList,
    isSearchGroupID,
    isSearchGroupName
);

Parameters

ParameterTypeRequiredDescription
baseOnBase<List<GroupInfo>>YesCallback delivering the asynchronous operation result.
keywordListList<String>YesList of query keyword strings. Avoid querying with empty keywords or when both toggles are false.
isSearchGroupIDbooleanYesWhether to search against group IDs: true to include, false to exclude.
isSearchGroupNamebooleanYesWhether to search against group names: true to include, false to exclude.

Return value

The successful callback returns a List<GroupInfo> containing all matching group records.

Search results reflect a local matching snapshot at query execution time. Returned groups do not necessarily indicate that the user has joined them; to verify membership, call Check group membership.