> ## 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.

# Ongoing Call

> In-call screen that joins the call session and renders the Calls SDK's call UI, for outgoing, answered incoming and group calls.

`CometChatOngoingCall` renders the active call: the Calls SDK's video tiles and controls (mute, camera, switch camera, end). `CometChatOngoingCallActivity` hosts it full-screen, supports picture-in-picture, and is where an answered incoming call ends up: your app's answer activity opens it with the answered call, and it joins the session.

***

## Where It Fits

Every call ends up here:

| Path | How the screen opens |
| - | - |
| Incoming call answered | The Push SDK starts your answer activity (`PNConfiguration.setAnswerActivity`), which builds the call with `CallRingingUtils.buildIncomingCall` and calls `CometChatOngoingCallActivity.launchOngoingCallActivity(context, call)` |
| Outgoing call answered | The [Outgoing Call](https://www.cometchat.com/docs/ui-kit/android/outgoing-call.md) screen hands over once the callee joins: XML Views embed `CometChatOngoingCall` in the same activity, Compose launches `CometChatOngoingCallActivity` |
| Group call / meeting | [Call Buttons](https://www.cometchat.com/docs/ui-kit/android/call-buttons.md) send a meeting message; tapping it launches the activity with `CallWorkFlow.MEETING` |
| Your own flow | `CometChatOngoingCallActivity.launchOngoingCallActivity(context, sessionId, callType)` or the component directly |

> [tab] Kotlin (XML Views)
>
> ```kotlin lines theme={null}
> import com.cometchat.uikit.kotlin.presentation.ongoingcall.ui.CometChatOngoingCallActivity
>
> CometChatOngoingCallActivity.launchOngoingCallActivity(
>     context = this,
>     sessionId = sessionId,
>     callType = CometChatConstants.CALL_TYPE_VIDEO
> )
> ```

> [tab] Jetpack Compose
>
> ```kotlin lines theme={null}
> import com.cometchat.uikit.compose.presentation.ongoingcall.ui.CometChatOngoingCallActivity
>
> CometChatOngoingCallActivity.launchOngoingCallActivity(
>     context = context,
>     sessionId = sessionId,
>     callType = CometChatConstants.CALL_TYPE_VIDEO
> )
> ```

***

## Quick Start

### From your answer activity (incoming calls)

The Push SDK opens your answer activity with the answered call in its intent. Turn it into a UI Kit `Call` and launch this screen; it asks for the microphone (and the camera for a video call) and joins:

```kotlin lines theme={null}
val incoming = CallBundles.getCall(intent) ?: return finish()
val call = CallRingingUtils.buildIncomingCall(
    sessionId = incoming.sessionId,
    callType = if (incoming.isVideo) CometChatConstants.CALL_TYPE_VIDEO else CometChatConstants.CALL_TYPE_AUDIO,
    receiverType = incoming.receiverType,
    receiverUid = incoming.receiverUid,
    callerUid = incoming.callerUid,
    callerName = incoming.callerName,
    callerAvatarUrl = incoming.callerAvatarUrl,
    initiatedAtMs = incoming.initiatedAtMs,
    conversationId = incoming.conversationId
)
CometChatOngoingCallActivity.launchOngoingCallActivity(this, call)
finish()
```

See [Calling Integration](https://www.cometchat.com/docs/ui-kit/android/calling-integration.md#step-3-configure-push-ringing) for the full answer activity and its manifest entry.

### Launching it yourself

> [tab] Kotlin (XML Views)
>
> ```kotlin lines theme={null}
> CometChatOngoingCallActivity.launchOngoingCallActivity(
>     context = this,
>     sessionId = sessionId,
>     callType = CometChatConstants.CALL_TYPE_AUDIO,
>     callWorkFlow = CallWorkFlow.DEFAULT,          // MEETING for a group call
>     callSettingsBuilder = null,                  // or your SessionSettingsBuilder
>     style = null
> )
> ```

> [tab] Jetpack Compose
>
> ```kotlin lines theme={null}
> CometChatOngoingCallActivity.launchOngoingCallActivity(
>     context = context,
>     sessionId = sessionId,
>     callType = CometChatConstants.CALL_TYPE_AUDIO,
>     callWorkFlow = CallWorkFlow.DEFAULT,          // MEETING for a group call
>     callSettingsBuilder = null,                  // or your SessionSettingsBuilder
>     style = null
> )
> ```

### Embedding the component

Use the component directly when you host the call in your own screen.

> [tab] Kotlin (XML Views)
>
> ```xml activity_call.xml lines theme={null}
> <com.cometchat.uikit.kotlin.presentation.ongoingcall.ui.CometChatOngoingCall
>     android:id="@+id/ongoing_call"
>     android:layout_width="match_parent"
>     android:layout_height="match_parent" />
> ```
>
> ```kotlin lines theme={null}
> val ongoingCall = findViewById<CometChatOngoingCall>(R.id.ongoing_call)
> ongoingCall.setSessionId(sessionId)
> ongoingCall.setCallType(CometChatConstants.CALL_TYPE_VIDEO)
> ongoingCall.setCallWorkFlow(CallWorkFlow.DEFAULT)
> ongoingCall.setSessionSettingsBuilder(CometChatCalls.SessionSettingsBuilder())
> ongoingCall.startCall()
> ```

> [tab] Jetpack Compose
>
> ```kotlin lines theme={null}
> CometChatOngoingCall(
>     sessionId = sessionId,
>     callType = CometChatConstants.CALL_TYPE_VIDEO,
>     callWorkFlow = CallWorkFlow.DEFAULT,
>     onCallEnded = { finish() },
>     onError = { e -> Log.e("Call", e.message ?: "") }
> )
> ```

Prerequisites: `CometChatUIKit.init()` with `setEnableCalling(true)`, a user logged in, and `com.cometchat:calls-sdk-android` in your app's dependencies (the UI Kit does not bundle it). There is nothing to declare for permissions: `RECORD_AUDIO` and `CAMERA` merge into your manifest from the SDKs and are requested at runtime.

***

## Actions and Events

### Callback Methods

#### `onCallEnded`

Fires when this device has left the session: the user tapped End, the other side hung up, the session timed out, or the connection closed. Close the screen here.

> [tab] Kotlin (XML Views)
>
> The hosting `CometChatOngoingCallActivity` finishes itself, and an embedded component finishes its host activity on `CallEnded` and `SessionTimeout` too. Observe the ViewModel's events only for your own clean-up:
>
> ```kotlin lines theme={null}
> lifecycleScope.launch {
>     ongoingCall.getViewModel()?.events?.collect { event ->
>         if (event is OngoingCallEvent.CallEnded) finish()
>     }
> }
> ```

> [tab] Jetpack Compose
>
> ```kotlin lines theme={null}
> CometChatOngoingCall(
>     sessionId = sessionId,
>     callType = callType,
>     onCallEnded = { finish() }
> )
> ```

#### `onError`

Fires when the session could not be joined (bad session id, no network, the Calls SDK not logged in). A denied microphone does not fire it: the call joins muted.

> [tab] Kotlin (XML Views)
>
> ```kotlin lines theme={null}
> ongoingCall.setOnError { exception ->
>     Log.e("OngoingCall", "Error: ${exception.message}")
> }
> ```

> [tab] Jetpack Compose
>
> ```kotlin lines theme={null}
> CometChatOngoingCall(
>     sessionId = sessionId,
>     callType = callType,
>     onError = { exception ->
>         Log.e("OngoingCall", "Error: ${exception.message}")
>     }
> )
> ```

### ViewModel Events (`OngoingCallEvent`)

| Event | Fires when |
| - | - |
| `CallEnded` | This device left the session (End tapped, remote hang-up, connection closed) |
| `SessionTimeout` | The session timed out |
| `UserJoined(userId, isCurrentUser)` | A participant joined |
| `UserLeft(userId)` | A participant left |
| `Error(exception)` | Joining the session failed |

### Global UI Events (`CometChatEvents.callEvents`)

| Event | Fires when | Payload |
| - | - | - |
| `CometChatCallEvent.CallEnded` | This device hangs up a 1:1 call (End, or the call screen's own leave button) that the screen was opened with, as your answer activity does with `launchOngoingCallActivity(context, call)`. Not emitted when the other side hangs up, when the connection closes, or for a screen opened with a session id | `Call` |

### SDK Events (Real-Time, Automatic)

| Calls SDK listener | Internal behavior |
| - | - |
| `SessionStatusListener.onSessionLeft` | Local clean-up, `CallEnded` |
| `SessionStatusListener.onSessionTimedOut` | `SessionTimeout`, screen ends |
| `SessionStatusListener.onConnectionClosed` | Screen ends, `CallEnded` (a join whose connection closed without a leave event) |
| `ParticipantEventListener.onParticipantJoined / Left` | `UserJoined` / `UserLeft` |
| `ButtonClickListener.onLeaveSessionButtonClicked` | The Calls SDK has already left; local clean-up only |

***

## Functionality

| Method (Kotlin XML) | Compose Parameter | Description |
| - | - | - |
| `setSessionId(id)` | `sessionId` | Session to join (required) |
| `setCallType(type)` | `callType` | `CometChatConstants.CALL_TYPE_AUDIO` or `CALL_TYPE_VIDEO`; sets the session type |
| `setCallWorkFlow(flow)` | `callWorkFlow` | `DEFAULT` for 1:1 calls, `MEETING` for group calls |
| `setSessionSettingsBuilder(builder)` | `callSettingsBuilder` | Calls SDK `SessionSettingsBuilder` for layout, controls, audio mode. The component sets the session type on it |
| `startCall()` | automatic | Joins the session |
| `setOnError { }` | `onError` | Error callback |
| `setStyle(style)` | `style` | Container styling |
| `getViewModel()` | `viewModel` | Access to state and events |

***

## Hang-up and clean-up

Hanging up leaves the Calls SDK session with `CallSession.leave()`; nothing is sent to the Chat SDK. For a 1:1 call (`DEFAULT`) the UI Kit also clears its active-call state and, when the screen was opened with a `Call`, emits `CometChatCallEvent.CallEnded` on `CometChatEvents.callEvents`. A hang-up by the other side clears the same state but emits no global event; observe the component's `CallEnded` instead. For a `MEETING` it only leaves and clears the meeting flag; the conference continues for the others.

`CometChatOngoingCallActivity` leaves the session when it is destroyed, but only its **own** session: after answering a second call over a live one, the Push SDK opens your answer activity again, which hands the new call to `CometChatOngoingCallActivity`. That intent arrives in `onNewIntent` (`SINGLE_TOP`); the activity starts a fresh instance for the new session and finishes itself, and the old screen's clean-up does not touch the new session.

***

## Picture-in-Picture

`CometChatOngoingCallActivity` declares `supportsPictureInPicture` and enters PiP when the user leaves the screen during a call; the Calls SDK switches to its PiP layout (`enablePictureInPictureLayout` / `disablePictureInPictureLayout`). Dismissing the PiP window ends the call. Nothing to configure.

***

## Second call during a call

Handled by the Push SDK: the new call rings over the live one with "Answering ends your current call". Answer leaves the live session, prepares the new one and opens your answer activity, which opens `CometChatOngoingCallActivity` for it; Decline sends `busy` and keeps the current call.

***

## Style

> [tab] Kotlin (XML Views)
>
> ```kotlin lines theme={null}
> val style = CometChatOngoingCallStyle.Builder(this)
>     .setBackgroundColor(Color.parseColor("#141414"))
>     .setProgressIndicatorColor(Color.parseColor("#6852D6"))
>     .setCornerRadius(0f)
>     .build()
>
> CometChatOngoingCallActivity.launchOngoingCallActivity(
>     context = this,
>     sessionId = sessionId,
>     callType = callType,
>     style = style
> )
> ```

> [tab] Jetpack Compose
>
> ```kotlin lines theme={null}
> CometChatOngoingCall(
>     sessionId = sessionId,
>     callType = callType,
>     style = CometChatOngoingCallStyle.default().copy(
>         backgroundColor = Color(0xFF141414),
>         progressIndicatorColor = Color(0xFF6852D6)
>     )
> )
> ```

The style covers the container around the call surface (background, progress indicator while joining, corner radius, stroke). The call UI itself (tiles, buttons, layouts) is the Calls SDK's and is configured through its `SessionSettingsBuilder`; see [Session Settings](https://www.cometchat.com/docs/calls/android/session-settings.md) and [Call Layouts](https://www.cometchat.com/docs/calls/android/call-layouts.md).

See [Component Styling](https://www.cometchat.com/docs/ui-kit/android/component-styling.md) for the full reference.

***

## Next Steps

> [card] [Calling Integration](https://www.cometchat.com/docs/ui-kit/android/calling-integration.md)
>
> Enable calling and push ringing

> [card] [Outgoing Call](https://www.cometchat.com/docs/ui-kit/android/outgoing-call.md)
>
> Calling and ringing states before the answer

> [card] [Call Logs](https://www.cometchat.com/docs/ui-kit/android/call-logs.md)
>
> View call history

> [card] [Push Ringing](https://www.cometchat.com/docs/calls/android/voip-calling.md)
>
> How incoming calls ring


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