Skip to main content
Version: 3.x.x

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.

  1. Leave - By using leave() function, only that participant leaves the meeting, and the meeting continues for the other participants.
  2. 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 onMeetingLeft of Meeting with a LeaveReason.
  • All remote participants will receive a callback onParticipantLeft with Participant object and a LeaveReason.

Event associated with end():

  • All remote participants and local participant will receive a callback on onMeetingLeft with a LeaveReason.
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