Leave or End Meeting - Android
A participant can leave the meeting at any time.
This guide shows how to leave or end a VideoSDK meeting.
- Leave - By using
leave()function, only that participant leaves the meeting, and the meeting continues for the other participants. - End - By using
end()function, meeting will end for each and every participant. So, use this function according to your use cases.
Leave And End Meeting
Both methods are suspend functions. Call them from a coroutine, such as lifecycleScope.launch (from androidx.lifecycle:lifecycle-runtime-ktx), and catch the VideoSDKException they throw when a call is refused or fails.
btnLeave!!.setOnClickListener { _: View? ->
lifecycleScope.launch {
try {
meeting!!.leave()
} catch (e: VideoSDKException) {
Log.e("VideoSDK", "leave() failed: ${e.code} ${e.name}")
}
}
}
btnEnd!!.setOnClickListener { _: View? ->
lifecycleScope.launch {
try {
meeting!!.end()
} catch (e: VideoSDKException) {
Log.e("VideoSDK", "end() failed: ${e.code} ${e.name}")
}
}
}
caution
Don't launch leave() with lifecycleScope from onDestroy(). That scope is already cancelled there, so the call never runs.
Events
Events associated with leave():
- Local participant will receive a callback on
onMeetingLeftofMeetingwith aLeaveReason. - All remote participants will receive a callback
onParticipantLeftwith Participant object and aLeaveReason.
Event associated with end():
- All remote participants and local participant will receive a callback on
onMeetingLeftwith aLeaveReason.
private val meetingEventListener = object : MeetingEventListener() {
override fun onMeetingLeft(reason: LeaveReason) {
Log.d("#meeting", "onMeetingLeft(): ${reason.message}")
}
override fun onParticipantLeft(participant: Participant, reason: LeaveReason) {
Log.d("#meeting", participant.displayName + " left")
}
}
Got a Question? Ask us on discord

