SDKsAndroid
Manage group administrators
Use SetGroupMemberInfo.roleLevel to change a member’s role in a group.
Update the administrative role level of a specified group member. Group owners can promote regular members to administrators or demote administrators back to regular members. To transfer group ownership, see Transfer group ownership.
Code example
SetGroupMemberInfo update = new SetGroupMemberInfo();
update.setGroupID("group_123");
update.setUserID("user_b");
update.setRoleLevel(GroupRole.ADMIN);
OpenIMClient.getInstance().groupManager.setGroupMemberInfo(
update,
new OnBase<String>() {
@Override
public void onSuccess(String data) {
// Group member role updated successfully
}
@Override
public void onError(int code, String error) {
// Failed to update group member role
}
}
);Role constants
Use constants defined in GroupRole to set the roleLevel:
| Constant | Value | Description |
|---|---|---|
GroupRole.MEMBER | 20 | Regular group member. |
GroupRole.ADMIN | 60 | Group administrator with member management and mute privileges. |
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
groupMemberInfo | SetGroupMemberInfo | Yes | Member update object. Must specify groupID, member userID, and the new role level constant roleLevel. |
base | OnBase<String> | Yes | Callback handler for the asynchronous request. |
Return value
Upon success, data in onSuccess returns a confirmation message.
State changes after the call
- Callback confirmation: The
onSuccesscallback indicates that the role change was committed on the server. - Asynchronous event delivery: Group members receive the
onGroupMemberInfoChangedevent delivering the updatedGroupMembersInfo. The client should merge the updatedroleLevelinto the cached member record usinggroupID:userIDas the unique key. - Re-query calibration: If administrator rosters diverge, call Get group owners and admins to reload the verified administrative list.
For complete listener registration and lifecycle management, see Group overview.
Was this page helpful?