Browse SDKs · Android
Platform
SDKsAndroid

Check users in a group

Use getUsersInGroup to select the users who are currently members of a group.

Copy

Filter a candidate list of user IDs to determine which users are already members of a specified group. This is typically used to validate and filter candidate lists before inviting users to a group.

Code example

String groupID = "group_123";
List<String> candidateUserIDs = Arrays.asList("user_a", "user_b", "user_c");

OpenIMClient.getInstance().groupManager.getUsersInGroup(
    new OnBase<List<String>>() {
        @Override
        public void onSuccess(List<String> joinedUserIDs) {
            // joinedUserIDs contains candidate users who are already in the group
        }

        @Override
        public void onError(int code, String error) {
            // Failed to query membership status
        }
    },
    groupID,
    candidateUserIDs
);

Parameters

ParameterTypeRequiredDescription
baseOnBase<List<String>>YesCallback handler for the asynchronous request.
groupIDStringYesGlobally unique ID of the target group.
candidateUserIDsList<String>YesList of candidate user IDs to check. Ensure duplicate or empty strings are removed before calling.

Return value

Upon success, onSuccess returns a list of user IDs (List<String>) that are already members of the group.

State changes after the call

  1. Snapshot check: This is a read-only query that checks user membership and does not alter group state.
  2. Detailed profiles: This method only returns user IDs. To retrieve detailed in-group profiles (such as nicknames, roles, or mute times), see Get group member profiles.