Remove Participant - Android
A host can remove a participant from the room, for example someone who is disrupting the session.
VideoSDK provides three ways to remove a participant from a room.
1. Using SDK
remove()
Call remove() on the remote Participant to remove them from the room.
remove() is a suspend function, so call it from a coroutine. It throws a VideoSDKException if the server refuses the request. Called before join(), or while the room is reconnecting, it reports 3035 or 3065 on onError and returns without throwing. Called while a join is still running, it waits for the join to finish first.
btnRemoveParticipant!!.setOnClickListener { _: View? ->
val remoteParticipantId = "<participant-id>"
// Get specific participant instance
val participant = room!!.participants[remoteParticipantId] ?: return@setOnClickListener
lifecycleScope.launch {
try {
// The removed participant gets onRoomLeft; everyone else gets onParticipantLeft
participant.remove()
} catch (e: VideoSDKException) {
Log.d("VideoSDK", "remove failed: ${e.code} ${e.message}")
}
}
}
Events associated with remove
The following callbacks are received when a participant is removed from the room.
- The participant who was removed receives
onRoomLeftwith the reasonLeaveReason.REMOVE_PEER. - Every other participant receives
onParticipantLeftwith the removedParticipantand aLeaveReason. Don't rely on that reason beingLeaveReason.REMOVE_PEER.
2. Using VideoSDK Dashboard
- You can go to the session page on VideoSDK Dashboard and select the room you want to remove a participant from.
- And then from the participants list you can remove any participant you want.
3. Using Rest API
- You can also remove the particular participant from the room using the REST API.
- To use this method, you should have the
sessionIdof the room andparticipantIdof the participant who is supposed to be removed.
API Reference
The API references for all the methods and events utilised in this guide are provided below.
Got a Question? Ask us on discord

