Skip to content
10 changes: 7 additions & 3 deletions calls/android/actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
<Tabs>
<Tab title="Kotlin">
```kotlin
val callSession = CallSession.getInstance()

Check warning on line 17 in calls/android/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/actions.mdx#L17

Did you really mean 'callSession'?
```
</Tab>
<Tab title="Java">
```java
CallSession callSession = CallSession.getInstance();

Check warning on line 22 in calls/android/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/actions.mdx#L22

'callSession' is repeated!

Check warning on line 22 in calls/android/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/actions.mdx#L22

Did you really mean 'callSession'?
```
</Tab>
</Tabs>
Expand Down Expand Up @@ -47,9 +47,9 @@
</Tab>
</Tabs>

### Unmute Audio

Check warning on line 50 in calls/android/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/actions.mdx#L50

Did you really mean 'Unmute'?

Unmutes your local microphone, resuming audio transmission.

Check warning on line 52 in calls/android/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/actions.mdx#L52

Did you really mean 'Unmutes'?

<Tabs>
<Tab title="Kotlin">
Expand Down Expand Up @@ -382,33 +382,37 @@
<Tabs>
<Tab title="Kotlin">
```kotlin
val isActive = callSession.isSessionActive()

Check warning on line 385 in calls/android/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/actions.mdx#L385

Did you really mean 'isActive'?
```
</Tab>
<Tab title="Java">
```java
boolean isActive = callSession.isSessionActive();

Check warning on line 390 in calls/android/actions.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/actions.mdx#L390

Did you really mean 'isActive'?
```
</Tab>
</Tabs>

### Leave Session

Ends your participation and disconnects gracefully. The call continues for other participants.
Ends your participation and disconnects gracefully. In a 1:1 call this is the hang-up: the other side receives `onParticipantLeft` and the backend records the end. In a group call the session continues for the other participants.

<Tabs>
<Tab title="Kotlin">
```kotlin
callSession.leaveSession()
callSession.leave()
```
</Tab>
<Tab title="Java">
```java
callSession.leaveSession();
callSession.leave();
```
</Tab>
</Tabs>

<Note>
`leaveSession()` is deprecated since 5.1 and only calls `leave()`. To end a call that is still ringing use `CometChatCalls.endCall(sessionId, status, listener)` with `cancelled` (caller) as described in [Ringing](/calls/android/ringing); `leave()` alone does not tell the other side why.
</Note>

### Raise Hand

Shows a hand-raised indicator to get attention from other participants.
Expand Down
8 changes: 4 additions & 4 deletions calls/android/custom-control-panel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
<Tabs>
<Tab title="Kotlin">
```kotlin
val sessionSettings = CometChatCalls.SessionSettingsBuilder()

Check warning on line 39 in calls/android/custom-control-panel.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/custom-control-panel.mdx#L39

Did you really mean 'sessionSettings'?
.hideControlPanel(true)
.build()
```
</Tab>
<Tab title="Java">
```java
SessionSettings sessionSettings = new CometChatCalls.SessionSettingsBuilder()

Check warning on line 46 in calls/android/custom-control-panel.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/custom-control-panel.mdx#L46

'sessionSettings' is repeated!

Check warning on line 46 in calls/android/custom-control-panel.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/custom-control-panel.mdx#L46

Did you really mean 'sessionSettings'?
.hideControlPanel(true)
.build();
```
Expand Down Expand Up @@ -206,7 +206,7 @@
}

btnEndCall.setOnClickListener {
callSession.leaveSession()
callSession.leave()
finish()
}
}
Expand Down Expand Up @@ -261,7 +261,7 @@
btnSwitchCamera.setOnClickListener(v -> callSession.switchCamera());

btnEndCall.setOnClickListener(v -> {
callSession.leaveSession();
callSession.leave();
finish();
});
}
Expand Down Expand Up @@ -470,7 +470,7 @@
}

btnEndCall.setOnClickListener {
callSession.leaveSession()
callSession.leave()
finish()
}
}
Expand Down Expand Up @@ -601,7 +601,7 @@
btnSwitchCamera.setOnClickListener(v -> callSession.switchCamera());

btnEndCall.setOnClickListener(v -> {
callSession.leaveSession();
callSession.leave();
finish();
});
}
Expand Down
120 changes: 110 additions & 10 deletions calls/android/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
description: "Handle CometChat Calls SDK v5 events on Android for call lifecycle, participants, media state, errors, and real-time updates."
---

Handle call session events to build responsive UIs. The SDK provides five event listener interfaces to monitor session status, participant activities, media changes, button clicks, and layout changes. Each listener is lifecycle-aware and automatically cleaned up when the Activity or Fragment is destroyed.
Handle call session events to build responsive UIs. The SDK provides five session listener interfaces to monitor session status, participant activities, media changes, button clicks, and layout changes, plus two global listeners for incoming calls and login state. Each listener is lifecycle-aware and automatically cleaned up when the Activity or Fragment is destroyed.

Check warning on line 8 in calls/android/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/events.mdx#L8

Did you really mean 'UIs'?

## Get CallSession Instance

Expand All @@ -14,16 +14,18 @@
<Tabs>
<Tab title="Kotlin">
```kotlin
val callSession = CallSession.getInstance()
val callSession = CometChatCalls.getActiveSession() // null when no session is prepared or joined

Check warning on line 17 in calls/android/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/events.mdx#L17

Did you really mean 'callSession'?
```
</Tab>
<Tab title="Java">
```java
CallSession callSession = CallSession.getInstance();
CallSession callSession = CometChatCalls.getActiveSession(); // null when no session is prepared or joined

Check warning on line 22 in calls/android/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/events.mdx#L22

'callSession' is repeated!

Check warning on line 22 in calls/android/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/events.mdx#L22

Did you really mean 'callSession'?
```
</Tab>
</Tabs>

`getActiveSession()` returns the session as soon as it is **prepared**, which is what `CometChatCalls.initiateCall` does on the caller and what the Push SDK's ring does on the callee, before anyone joins. That is what lets a caller listen for "ringing" and "answered" without joining (see [Ringing](/calls/android/ringing)). `CallSession.getInstance()` still works and returns the same object.

Check warning on line 27 in calls/android/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/events.mdx#L27

Did you really mean 'callee'?

<Note>
All event listeners are lifecycle-aware and automatically removed when the `LifecycleOwner` (Activity/Fragment) is destroyed. You don't need to manually remove listeners.
</Note>
Expand Down Expand Up @@ -60,7 +62,8 @@
}

override fun onConnectionClosed() {
// Connection permanently closed
// Connection permanently closed. On a session that was only prepared
// (an outgoing call still ringing), this means the call ended before anyone joined.
finish()
}
})
Expand Down Expand Up @@ -108,11 +111,11 @@
| Event | Description |
|-------|-------------|
| `onSessionJoined()` | Successfully connected and joined the session |
| `onSessionLeft()` | Left the session via `leaveSession()` or was removed |
| `onSessionTimedOut()` | Session ended due to inactivity timeout |
| `onSessionLeft()` | Left the session via `leave()` or was removed |
| `onSessionTimedOut()` | Session ended due to inactivity timeout. On a prepared session: nobody joined in time |
| `onConnectionLost()` | Network interrupted, SDK attempting reconnection |
| `onConnectionRestored()` | Connection restored after being lost |
| `onConnectionClosed()` | Connection permanently closed, cannot reconnect |
| `onConnectionClosed()` | Connection permanently closed, cannot reconnect. On a prepared session: the call ended before anyone joined (declined, cancelled from another device, or the room went away); the reason arrives through `onIncomingCallEnded` |

---

Expand All @@ -124,8 +127,13 @@
<Tab title="Kotlin">
```kotlin
callSession.addParticipantEventListener(this, object : ParticipantEventListener() {
override fun onParticipantConnected(participant: Participant) {
// A participant's device prepared the session but has not joined yet.
// On an outgoing call: the callee's phone is ringing.
}

override fun onParticipantJoined(participant: Participant) {
// A participant joined the call
// A participant joined the call. On an outgoing call: the callee answered.
}

override fun onParticipantLeft(participant: Participant) {
Expand Down Expand Up @@ -153,9 +161,15 @@
<Tab title="Java">
```java
callSession.addParticipantEventListener(this, new ParticipantEventListener() {
@Override
public void onParticipantConnected(Participant participant) {
// A participant's device prepared the session but has not joined yet.
// On an outgoing call: the callee's phone is ringing.
}

@Override
public void onParticipantJoined(Participant participant) {
// A participant joined the call
// A participant joined the call. On an outgoing call: the callee answered.
}

@Override
Expand All @@ -176,11 +190,12 @@

| Event | Parameter | Description |
|-------|-----------|-------------|
| `onParticipantJoined` | `Participant` | A participant connected to the call |
| `onParticipantConnected` | `Participant` | A participant's device prepared the session without joining. On the caller's prepared session this is the callee ringing |

Check warning on line 193 in calls/android/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/events.mdx#L193

Did you really mean 'callee'?
| `onParticipantJoined` | `Participant` | A participant joined the call. On the caller's prepared session this is the callee answering: join now |

Check warning on line 194 in calls/android/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/events.mdx#L194

Did you really mean 'callee'?
| `onParticipantLeft` | `Participant` | A participant disconnected from the call |
| `onParticipantListChanged` | `List<Participant>` | Participant list updated |
| `onParticipantAudioMuted` | `Participant` | A participant muted their microphone |
| `onParticipantAudioUnmuted` | `Participant` | A participant unmuted their microphone |

Check warning on line 198 in calls/android/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/events.mdx#L198

Did you really mean 'unmuted'?
| `onParticipantVideoPaused` | `Participant` | A participant turned off their camera |
| `onParticipantVideoResumed` | `Participant` | A participant turned on their camera |
| `onParticipantHandRaised` | `Participant` | A participant raised their hand |
Expand Down Expand Up @@ -288,7 +303,7 @@
| Event | Parameter | Description |
|-------|-----------|-------------|
| `onAudioMuted` | - | Your microphone was muted |
| `onAudioUnMuted` | - | Your microphone was unmuted |

Check warning on line 306 in calls/android/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/events.mdx#L306

Did you really mean 'unmuted'?
| `onVideoPaused` | - | Your camera was turned off |
| `onVideoResumed` | - | Your camera was turned on |
| `onRecordingStarted` | - | Call recording started |
Expand Down Expand Up @@ -474,3 +489,88 @@
| `LayoutType.TILE` | Grid layout with equally-sized tiles | Group discussions, team meetings |
| `LayoutType.SPOTLIGHT` | Large view for active speaker, small tiles for others | Presentations, one-on-one calls |
</Accordion>

---

## Incoming Call Events

`CometChatCalls.addIncomingCallListener` is a global listener, not tied to a session. It reports a call for the logged-in user starting and ending, on both sides of the call, whether the call arrived by push while the app was killed or while it was running. It is how a caller learns why an outgoing call ended, and how your own screens stay in sync with calls the Push SDK rings.

<Tabs>
<Tab title="Kotlin">
```kotlin
CometChatCalls.addIncomingCallListener("my-screen", object : CometChatCalls.IncomingCallListener() {
override fun onIncomingCallReceived(call: InitiatedCall) {
// A call for this user is ringing (the Push SDK already shows it)
}

override fun onIncomingCallEnded(call: InitiatedCall, reason: String) {
// The ring ended, or your outgoing call ended: "rejected", "busy", "unanswered", "cancelled", "ongoing"
}
})

CometChatCalls.removeIncomingCallListener("my-screen")
```
</Tab>
<Tab title="Java">
```java
CometChatCalls.addIncomingCallListener("my-screen", new CometChatCalls.IncomingCallListener() {
@Override
public void onIncomingCallReceived(InitiatedCall call) {
// A call for this user is ringing (the Push SDK already shows it)
}

@Override
public void onIncomingCallEnded(InitiatedCall call, String reason) {
// The ring ended, or your outgoing call ended: "rejected", "busy", "unanswered", "cancelled", "ongoing"
}
});

CometChatCalls.removeIncomingCallListener("my-screen");
```
</Tab>
</Tabs>

| Event | Parameters | Description |
|-------|------------|-------------|
| `onIncomingCallReceived` | `InitiatedCall` | A call for the logged-in user is ringing |
| `onIncomingCallEnded` | `InitiatedCall`, `reason` | The call ended before being answered here. Caller: `rejected`, `busy`, `unanswered`, `cancelled`. Callee still ringing: `cancelled`, `ongoing` (answered elsewhere), `rejected` / `busy` (declined here), `unanswered` |

Check warning on line 537 in calls/android/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/events.mdx#L537

Did you really mean 'Callee'?

`InitiatedCall` carries `sessionId`, `messageId`, `conversationId`, `sender`, `senderName`, `senderAvatar`, `receiver`, `receiverType`, `type`, `status` and `initiatedAt`.

<Note>
Listener ids are keys: registering the same id twice replaces the earlier listener. This listener is not lifecycle-aware; remove it when the screen is destroyed.
</Note>

---

## Login Events

`CometChatCalls.addLoginListener` reports the Calls SDK login state. The Push SDK uses it to register and unregister the push token and to stop a ring when the user logs out; your app can use it to gate call UI.

Check warning on line 549 in calls/android/events.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

calls/android/events.mdx#L549

Did you really mean 'unregister'?

<Tabs>
<Tab title="Kotlin">
```kotlin
CometChatCalls.addLoginListener("my-app", object : CometChatCalls.LoginListener() {
override fun loginSuccess(user: CallUser) {}
override fun loginFailure(e: CometChatException) {}
override fun logoutSuccess() {}
override fun logoutFailure(e: CometChatException) {}
})

CometChatCalls.removeLoginListener("my-app")
```
</Tab>
<Tab title="Java">
```java
CometChatCalls.addLoginListener("my-app", new CometChatCalls.LoginListener() {
@Override public void loginSuccess(CallUser user) {}
@Override public void loginFailure(CometChatException e) {}
@Override public void logoutSuccess() {}
@Override public void logoutFailure(CometChatException e) {}
});

CometChatCalls.removeLoginListener("my-app");
```
</Tab>
</Tabs>
Loading
Loading