Skip to main content
Control the call session lifecycle and participant interactions. These methods allow you to leave the session, raise/lower your hand, and check session status.

Prerequisites

Get CallSession Instance

Session control methods are called on the CallSession singleton:
val callSession = CallSession.getInstance()

Check Session Status

Check if there is currently an active call session.
val isActive = callSession.isSessionActive()

if (isActive) {
    Log.d(TAG, "Call session is active")
} else {
    Log.d(TAG, "No active call session")
}
Return TypeDescription
Booleantrue if a session is active, false otherwise
Use this method to check session status before calling other CallSession methods, or to determine if you need to show call UI.

Leave Session

End your participation in the current call session.
callSession.leaveSession()
When you leave the session, the onSessionLeft() callback is triggered on your SessionStatusListener. Other participants will receive the onParticipantLeft(Participant) callback.

Handling Session End

callSession.addSessionStatusListener(this, object : SessionStatusListener {
    override fun onSessionLeft() {
        Log.d(TAG, "Successfully left the session")
        // Navigate away from call screen
        finish()
    }

    override fun onSessionJoined() {}
    override fun onSessionTimedOut() {}
    override fun onConnectionLost() {}
    override fun onConnectionRestored() {}
    override fun onConnectionClosed() {}
})

Raise Hand

Raise your hand to get attention from other participants. This is useful in meetings or webinars when you want to ask a question or make a comment.
callSession.raiseHand()
When you raise your hand, all participants receive the onParticipantHandRaised(Participant) callback on their ParticipantEventListener.

Lower Hand

Lower your previously raised hand.
callSession.lowerHand()
When you lower your hand, all participants receive the onParticipantHandLowered(Participant) callback on their ParticipantEventListener.

Listen for Hand Raise Events

Register a ParticipantEventListener to receive callbacks when participants raise or lower their hands:
callSession.addParticipantEventListener(this, object : ParticipantEventListener {
    override fun onParticipantHandRaised(participant: Participant) {
        Log.d(TAG, "${participant.name} raised their hand")
        // Show hand raised indicator in UI
    }

    override fun onParticipantHandLowered(participant: Participant) {
        Log.d(TAG, "${participant.name} lowered their hand")
        // Hide hand raised indicator in UI
    }

    // Other callbacks...
    override fun onParticipantJoined(participant: Participant) {}
    override fun onParticipantLeft(participant: Participant) {}
    override fun onParticipantAudioMuted(participant: Participant) {}
    override fun onParticipantAudioUnmuted(participant: Participant) {}
    override fun onParticipantVideoPaused(participant: Participant) {}
    override fun onParticipantVideoResumed(participant: Participant) {}
    override fun onParticipantStartedScreenShare(participant: Participant) {}
    override fun onParticipantStoppedScreenShare(participant: Participant) {}
    override fun onParticipantStartedRecording(participant: Participant) {}
    override fun onParticipantStoppedRecording(participant: Participant) {}
    override fun onDominantSpeakerChanged(participant: Participant) {}
    override fun onParticipantListChanged(participants: List<Participant>) {}
})

Button Click Listeners

Listen for when users tap the leave or raise hand buttons:
callSession.addButtonClickListener(this, object : ButtonClickListener {
    override fun onLeaveSessionButtonClicked() {
        Log.d(TAG, "Leave button clicked")
        // Optionally show confirmation dialog before leaving
    }

    override fun onRaiseHandButtonClicked() {
        Log.d(TAG, "Raise hand button clicked")
        // Handle custom raise hand logic if needed
    }

    // Other callbacks...
    override fun onShareInviteButtonClicked() {}
    override fun onChangeLayoutButtonClicked() {}
    override fun onParticipantListButtonClicked() {}
    override fun onToggleAudioButtonClicked() {}
    override fun onToggleVideoButtonClicked() {}
    override fun onSwitchCameraButtonClicked() {}
    override fun onChatButtonClicked() {}
    override fun onRecordingToggleButtonClicked() {}
})

Hide Session Control Buttons

Control the visibility of session control buttons in the UI:
val sessionSettings = CometChatCalls.SessionSettingsBuilder()
    .hideLeaveSessionButton(false)  // Show leave button
    .hideRaiseHandButton(false)     // Show raise hand button
    .hideShareInviteButton(true)    // Hide share invite button
    .build()

Session Timeout

Configure the idle timeout period for when you’re alone in a session:
val sessionSettings = CometChatCalls.SessionSettingsBuilder()
    .setIdleTimeoutPeriod(300)  // 300 seconds (5 minutes)
    .build()
When the timeout is reached, the onSessionTimedOut() callback is triggered:
callSession.addSessionStatusListener(this, object : SessionStatusListener {
    override fun onSessionTimedOut() {
        Log.d(TAG, "Session timed out due to inactivity")
        // Handle timeout - navigate away from call screen
        finish()
    }

    override fun onSessionJoined() {}
    override fun onSessionLeft() {}
    override fun onConnectionLost() {}
    override fun onConnectionRestored() {}
    override fun onConnectionClosed() {}
})

Next Steps