> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Leave Group

> Leave CometChat groups with the Android SDK to stop receiving group messages and update group membership state.

> [accordion] AI Integration Quick Reference
>
> ```kotlin theme={null}
> // Leave a group
> CometChat.leaveGroup("GUID", object : CometChat.CallbackListener<String>() {
>     override fun onSuccess(message: String) { }
>     override fun onError(e: CometChatException) { }
> })
>
> // Listen for member left events
> CometChat.addGroupListener("LISTENER_ID", object : GroupListener() {
>     override fun onGroupMemberLeft(action: Action?, leftUser: User?, leftGroup: Group?) { }
> })
> ```

## Leave a Group

Use `leaveGroup()` to stop receiving updates and messages for a group.

> [tab] Java
>
> ```java theme={null}
> private String GUID = "GUID";
>
> CometChat.leaveGroup(GUID, new CometChat.CallbackListener<String>() {
>   @Override
>   public void onSuccess(String successMessage) {
>     Log.d(TAG, successMessage);
>   }
>
>   @Override
>   public void onError(CometChatException e) {
>     Log.d(TAG, "Group leaving failed with exception: " + e.getMessage());
>   }
> });
> ```

> [tab] Kotlin
>
> ```kotlin theme={null}
> val GUID:String="GUID"
>
> CometChat.leaveGroup(GUID,object :CometChat.CallbackListener<String>(){
>   override fun onSuccess(p0: String?) {
>     Log.d(TAG, "Group left successfully")
>   }
>
>   override fun onError(p0: CometChatException?) {
>     Log.d(TAG, "Group leaving failed with exception: " + p0?.message)
>   }
> })
> ```

| Parameter | Description |
| - | - |
| `GUID` | The GUID of the group you would like to leave |

Once a group is left, the user will no longer receive any updates or messages pertaining to the group.

## Real-Time Group Member Left Events

When a user leaves a group, members receive a real-time event in `onGroupMemberLeft()` of the `GroupListener` class. The callback provides an [`Action`](https://www.cometchat.com/docs/sdk/reference/messages#action) object, the left [`User`](https://www.cometchat.com/docs/sdk/reference/entities#user), and the [`Group`](https://www.cometchat.com/docs/sdk/reference/entities#group).

> [tab] Java
>
> ```java theme={null}
> CometChat.addGroupListener(UNIQUE_LISTENER_ID, new CometChat.GroupListener() {
>   @Override
>   public void onGroupMemberLeft(Action action, User leftUser, Group leftGroup) {
>     Log.d(TAG, "User left");
>   }
> });
> ```

> [tab] Kotlin
>
> ```kotlin theme={null}
> CometChat.addGroupListener(UNIQUE_LISTENER_ID, object : GroupListener() {
>   override fun onGroupMemberLeft(action: Action?, leftUser: User?, leftGroup: Group?) {
>     Log.d(TAG, "User left")
>   }
> })
> ```

## Missed Group Member Left Events

When fetching message history, if a member left a group the logged-in user is part of, the list will contain an [`Action`](https://www.cometchat.com/docs/sdk/reference/messages#action) message with these fields:

1. `action` - `left`
2. `actionBy` - [`User`](https://www.cometchat.com/docs/sdk/reference/entities#user) object containing the details of the user who left the group
3. `actionFor` - [`Group`](https://www.cometchat.com/docs/sdk/reference/entities#group) object containing the details of the group the user has left

> [!WARNING]
>
> Always remove group listeners when they're no longer needed (e.g., in `onDestroy()` or when navigating away). Failing to remove listeners can cause memory leaks and duplicate event handling.

***

## Next Steps

> [card] [Join Group](https://www.cometchat.com/docs/sdk/android/v4/join-group.md)
>
> Rejoin groups or join new ones

> [card] [Delete Group](https://www.cometchat.com/docs/sdk/android/v4/delete-group.md)
>
> Permanently delete groups you own

> [card] [Retrieve Groups](https://www.cometchat.com/docs/sdk/android/v4/retrieve-groups.md)
>
> Fetch list of available groups

> [card] [Group Listeners](https://www.cometchat.com/docs/sdk/android/v4/real-time-listeners.md)
>
> Handle real-time group events


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.