Group overview
Understand group concepts, core data types, and main capabilities in the Android SDK.
OpenIMSDK uses groups to hold shared profiles, memberships, and permissions for multi-user chats. groupID is the stable group identifier used to send group messages, retrieve group profiles, manage members, and handle join applications. A group conversation in the current user's chat list is still managed by conversationID; do not interchange these identifiers.
Core data types
| Type | Purpose |
|---|---|
GroupInfo | Group name, avatar, announcement, owner, verification settings, member count, and extension data. |
GroupMembersInfo | A user's nickname, role, mute state, and join information in a specified group. |
GroupApplicationInfo | A group application and its handling state. |
Group member roles use GroupRole: MEMBER is a regular member, ADMIN is an administrator, and OWNER is the group owner.
Main capabilities
- Group profile and settings
- Group permissions
- Joining and leaving groups
- Retrieving groups
- Group applications
- Retrieving group members
- Managing group members
State updates
Call setOnGroupListener() before login to register an OnGroupListener for group profile, membership, and group application changes. The following example shows where the application can refresh the relevant screen for each callback:
private final OnGroupListener groupListener = new OnGroupListener() {
@Override
public void onJoinedGroupAdded(GroupInfo group) {
// Refresh the joined-group list.
}
@Override
public void onJoinedGroupDeleted(GroupInfo group) {
// Refresh the joined-group list.
}
@Override
public void onGroupInfoChanged(GroupInfo group) {
// Refresh the group profile for group.getGroupID().
}
@Override
public void onGroupDismissed(GroupInfo group) {
// Close the dismissed group chat for group.getGroupID().
}
@Override
public void onGroupMemberAdded(GroupMembersInfo member) {
// Refresh the member list for member.getGroupID().
}
@Override
public void onGroupMemberDeleted(GroupMembersInfo member) {
// Refresh the member list for member.getGroupID().
}
@Override
public void onGroupMemberInfoChanged(GroupMembersInfo member) {
// Refresh the member list for member.getGroupID().
}
@Override
public void onGroupApplicationAdded(GroupApplicationInfo application) {
// Refresh the group application list.
}
@Override
public void onGroupApplicationAccepted(GroupApplicationInfo application) {
// Refresh the group application list.
}
@Override
public void onGroupApplicationRejected(GroupApplicationInfo application) {
// Refresh the group application list.
}
@Override
public void onGroupApplicationDeleted(GroupApplicationInfo application) {
// Refresh the group application list.
}
};
public void registerGroupListener() {
OpenIMClient.getInstance().groupManager.setOnGroupListener(groupListener);
}Use onJoinedGroupAdded and onJoinedGroupDeleted to update the current user's joined-group list. Use onGroupInfoChanged and onGroupDismissed to update a group profile or close a dismissed group chat. Handle membership changes with onGroupMemberAdded, onGroupMemberDeleted, and onGroupMemberInfoChanged, and handle group application changes with the four onGroupApplication... callbacks.
A group API success callback indicates that the call completed. When group profiles, members, or group application lists need updating, refresh the screen or query the data again based on the corresponding listener callback.
Was this page helpful?