Overview
This section demonstrates how to implement calling functionality using only the CometChat Calls SDK, without requiring the Chat SDK. This is ideal for applications that need video/audio calling capabilities without the full chat infrastructure.Before you begin, ensure you have completed the Calls SDK setup.
User Authentication
To start a call session, you need a user auth token. Since this implementation doesn’t use the Chat SDK, you’ll need to obtain the auth token via the CometChat REST API.To understand user authentication in CometChat, see the User Auth documentation.
- Create Auth Token — Creates a new auth token for a user
- Get Auth Token — Retrieves an existing auth token
For testing or POC purposes, you can create an auth token directly from the CometChat Dashboard. Navigate to Users & Groups → Users, select a user, and click + Create Auth Token.
Generate Call Token
A call token is required for secure access to a call session. Each token is unique to a specific session and user combination, ensuring that only authorized users can join the call. You can generate the token just before starting the call, or generate and store it ahead of time based on your use case. Use thegenerateToken() method to create a call token:
- Java
- Kotlin
Start Call Session
Use thestartSession() method to join a call session. This method requires a call token (generated in the previous step) and a CallSettings object that configures the call UI and behavior.
The CallSettings class configures the call UI and behavior. Use CallSettingsBuilder to create a CallSettings instance with the following required parameters:
- Java
- Kotlin
Call Settings
Configure the call experience using the followingCallSettingsBuilder methods:
Call Listeners
TheCometChatCallsEventsListener interface provides real-time callbacks for call session events, including participant changes, call state updates, and error conditions. Register this listener in any activity or fragment where you need to respond to call events.
Each listener requires a unique listenerId string. This ID is used to:
- Prevent duplicate registrations — Re-registering with the same ID replaces the existing listener
- Enable targeted removal — Remove specific listeners without affecting others
- Java
- Kotlin
Events
End Call Session
To end the call session and release all media resources (camera, microphone, network connections), callCometChatCalls.endSession() in the onCallEndButtonPressed() callback.
- Java
- Kotlin
Methods
These methods are available for performing custom actions during an active call session. Use them to build custom UI controls or implement specific behaviors based on your use case.These methods can only be called when a call session is active.
Switch Camera
Toggles between the front and rear camera during a video call. Useful for allowing users to switch their camera view without leaving the call.- Java
- Kotlin
Mute Audio
Controls the local audio stream transmission. When muted, other participants cannot hear the local user.true— Mutes the microphone, stops transmitting audiofalse— Unmutes the microphone, resumes audio transmission
- Java
- Kotlin
Pause Video
Controls the local video stream transmission. When paused, other participants see a frozen frame or avatar instead of live video.true— Pauses the camera, stops transmitting videofalse— Resumes the camera, continues video transmission
- Java
- Kotlin
Set Audio Mode
Routes the audio output to a specific device. Use this to let users choose between speaker, earpiece, or connected audio devices. Available modes:CometChatCallsConstants.AUDIO_MODE_SPEAKER— Device speaker (loudspeaker)CometChatCallsConstants.AUDIO_MODE_EARPIECE— Phone earpieceCometChatCallsConstants.AUDIO_MODE_BLUETOOTH— Connected Bluetooth deviceCometChatCallsConstants.AUDIO_MODE_HEADPHONES— Wired headphones
- Java
- Kotlin
Enter PIP Mode
Enters Picture-in-Picture mode, rendering the call view in a small floating window. This allows users to multitask while staying on the call. Ensure your app has PIP support enabled in the manifest.- Java
- Kotlin
Exit PIP Mode
Exits Picture-in-Picture mode and returns the call view to its original full-screen or embedded layout.- Java
- Kotlin
Switch To Video Call
Upgrades an ongoing audio call to a video call. This enables the camera and starts transmitting video to other participants. The remote participant receives theonCallSwitchedToVideo() callback.
- Java
- Kotlin
Start Recording
Starts recording the call session. The recording is saved to the CometChat server and can be accessed later. All participants receive theonRecordingToggled() callback when recording starts.
- Java
- Kotlin
Stop Recording
Stops an ongoing call recording. All participants receive theonRecordingToggled() callback when recording stops.
- Java
- Kotlin
End Call
Terminates the current call session and releases all media resources (camera, microphone, network connections). After calling this method, the call view should be closed.- Java
- Kotlin