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()
CallSession 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")
}
boolean isActive = callSession.isSessionActive();
if (isActive) {
Log.d(TAG, "Call session is active");
} else {
Log.d(TAG, "No active call session");
}
| Return Type | Description |
|---|
Boolean | true 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()
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() {}
})
callSession.addSessionStatusListener(this, new SessionStatusListener() {
@Override
public void onSessionLeft() {
Log.d(TAG, "Successfully left the session");
// Navigate away from call screen
finish();
}
@Override
public void onSessionJoined() {}
@Override
public void onSessionTimedOut() {}
@Override
public void onConnectionLost() {}
@Override
public void onConnectionRestored() {}
@Override
public void 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.
When you raise your hand, all participants receive the onParticipantHandRaised(Participant) callback on their ParticipantEventListener.
Lower Hand
Lower your previously raised hand.
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>) {}
})
callSession.addParticipantEventListener(this, new ParticipantEventListener() {
@Override
public void onParticipantHandRaised(Participant participant) {
Log.d(TAG, participant.getName() + " raised their hand");
// Show hand raised indicator in UI
}
@Override
public void onParticipantHandLowered(Participant participant) {
Log.d(TAG, participant.getName() + " lowered their hand");
// Hide hand raised indicator in UI
}
// Other callbacks...
@Override
public void onParticipantJoined(Participant participant) {}
@Override
public void onParticipantLeft(Participant participant) {}
@Override
public void onParticipantAudioMuted(Participant participant) {}
@Override
public void onParticipantAudioUnmuted(Participant participant) {}
@Override
public void onParticipantVideoPaused(Participant participant) {}
@Override
public void onParticipantVideoResumed(Participant participant) {}
@Override
public void onParticipantStartedScreenShare(Participant participant) {}
@Override
public void onParticipantStoppedScreenShare(Participant participant) {}
@Override
public void onParticipantStartedRecording(Participant participant) {}
@Override
public void onParticipantStoppedRecording(Participant participant) {}
@Override
public void onDominantSpeakerChanged(Participant participant) {}
@Override
public void onParticipantListChanged(List<Participant> participants) {}
});
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() {}
})
callSession.addButtonClickListener(this, new ButtonClickListener() {
@Override
public void onLeaveSessionButtonClicked() {
Log.d(TAG, "Leave button clicked");
// Optionally show confirmation dialog before leaving
}
@Override
public void onRaiseHandButtonClicked() {
Log.d(TAG, "Raise hand button clicked");
// Handle custom raise hand logic if needed
}
// Other callbacks...
@Override
public void onShareInviteButtonClicked() {}
@Override
public void onChangeLayoutButtonClicked() {}
@Override
public void onParticipantListButtonClicked() {}
@Override
public void onToggleAudioButtonClicked() {}
@Override
public void onToggleVideoButtonClicked() {}
@Override
public void onSwitchCameraButtonClicked() {}
@Override
public void onChatButtonClicked() {}
@Override
public void onRecordingToggleButtonClicked() {}
});
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()
SessionSettings sessionSettings = new 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()
SessionSettings sessionSettings = new 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() {}
})
callSession.addSessionStatusListener(this, new SessionStatusListener() {
@Override
public void onSessionTimedOut() {
Log.d(TAG, "Session timed out due to inactivity");
// Handle timeout - navigate away from call screen
finish();
}
@Override
public void onSessionJoined() {}
@Override
public void onSessionLeft() {}
@Override
public void onConnectionLost() {}
@Override
public void onConnectionRestored() {}
@Override
public void onConnectionClosed() {}
});
Next Steps