Get CallSession Instance
TheCallSession is a singleton that manages the active call. All event listener registrations and session control methods are accessed through this instance.
- Kotlin
- Java
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). Before a session is prepared or joined, getActiveSession() returns null, so a listener added through it is skipped; the Kotlin samples below use callSession?. for that reason, and in Java check callSession != null before adding one. Add listeners once joinSession (or a prepare) has succeeded, or register them earlier through CallSession.getInstance(), which returns the same object.
All session event listeners are lifecycle-aware and automatically removed when the
LifecycleOwner (Activity/Fragment) is destroyed. You don’t need to manually remove listeners.Session Events
Monitor the call session lifecycle including join/leave events and connection status.- Kotlin
- Java
Participant Events
Monitor participant activities including join/leave, audio/video state, hand raise, screen sharing, and recording.- Kotlin
- Java
Media Events
Monitor your local media state changes including audio/video status, recording, and device changes.- Kotlin
- Java
Screen sharing events are not on
MediaEventsListener. A participant’s screen share is reported by
ParticipantEventListener.onParticipantStartedScreenShare / onParticipantStoppedScreenShare — see
Screen Sharing. Starting a screen share from Android is opt-in: the screen share button appears only after your app declares the mediaProjection service (see Enable Screen Sharing).AudioMode Values
AudioMode Values
CameraFacing Values
CameraFacing Values
Button Click Events
Intercept UI button clicks from the default call interface to add custom behavior or analytics.- Kotlin
- Java
Button click events fire before the SDK’s default action executes. Use these to add custom logic alongside default behavior.
Layout Events
Monitor layout changes including layout type switches and Picture-in-Picture mode transitions.- Kotlin
- Java
LayoutType Values
LayoutType Values
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.
- Kotlin
- Java
InitiatedCall carries sessionId, messageId, conversationId, sender, senderName, senderAvatar, receiver, receiverType, type, status and initiatedAt.
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.
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.
- Kotlin
- Java