Browse SDKs · Android
Platform
SDKsAndroid

Create a group

Create a group with initial members, administrators, and an owner using createGroup().

Copy

Create a group and configure its initial profile. Populate the GroupInfo payload with basic properties such as group name and description, and supply lists specifying initial members, administrators, and the group owner. The successful callback delivers the created GroupInfo containing the server-assigned groupID.

Code example

GroupInfo info = new GroupInfo();
info.setGroupName("Project Discussion");
info.setIntroduction("Project members only");

List<String> memberUserIDs = Arrays.asList("user_a", "user_b");
List<String> adminUserIDs = Arrays.asList("user_c");
String ownerUserID = "user_owner";

OpenIMClient.getInstance().groupManager.createGroup(
    memberUserIDs,
    adminUserIDs,
    info,
    ownerUserID,
    new OnBase<GroupInfo>() {
        @Override
        public void onSuccess(GroupInfo group) {
            // group contains the created group information and groupID
        }

        @Override
        public void onError(int code, String error) {
            // Handle creation failure
        }
    }
);

Parameters

ParameterTypeRequiredDescription
memberUserIDsList<String>NoList of initial standard member user IDs; pass an empty list if none.
adminUserIDsList<String>NoList of initial administrator user IDs; do not overlap with members or the owner.
infoGroupInfoYesGroup profile configuration object; must include groupName.
ownerUserIDStringYesUser ID designated as the group owner; must not overlap with member or admin lists.
baseOnBase<GroupInfo>YesCallback delivering the asynchronous operation result.

Return value

The successful callback returns the created GroupInfo entity. Extract groupID to initiate group messages, query group metadata, or moderate members.

State changes after the call

A successful callback confirms that group creation completed on the server. The authenticated user and included members receive real-time notifications via the onJoinedGroupAdded event on OnGroupListener. Merge the new group entry into your local cache using groupID. For complete listener registration details, see Group overview.