Room Events - Android
These RoomEventListener events tell you the current state of the room. Override the ones you need and register the listener with room.addEventListener().
onRoomJoined
- This event is triggered when the room is successfully joined.
- It fires again after a reconnect that needed a fresh join, and after
switchTo(), so don't use it for one-time setup. switchRoomIdis the ID of the room you switched to withswitchTo(). It isnullon every other join.
onRoomLeft
- This event is triggered when the room is left.
- It fires on every way out, such as
leave(),end(), being removed from the room, the same participant ID joining from another device, or reconnecting giving up. reasonis aLeaveReasonthat tells you why, for exampleMANUAL_LEAVE_CALLEDafterleave().
onSpeakerChanged
- This event is triggered when the active speaker in the room gets changed.
activeSpeakerIdisnullwhen no one is speaking.room.getActiveSpeakerId()returns the same value at any time.
onPresenterChanged
- This event is triggered when the presenter in the room gets changed.
presenterIdisnullwhen screen sharing stops.room.getActivePresenterId()returns the same value at any time.
Example
Here is the usage of all the events mentioned in this page.
private val roomEventListener: RoomEventListener = object : RoomEventListener() {
override fun onRoomJoined(switchRoomId: String?) {
Log.d("VideoSDK", "onRoomJoined: ")
}
override fun onRoomLeft(reason: LeaveReason) {
Log.d("VideoSDK", "onRoomLeft: ${reason.message}")
}
override fun onSpeakerChanged(activeSpeakerId: String?) {
Log.d("VideoSDK", "onSpeakerChanged: $activeSpeakerId")
}
override fun onPresenterChanged(presenterId: String?) {
Log.d("VideoSDK", "onPresenterChanged: $presenterId")
}
}
override fun onCreate(savedInstanceState: Bundle?) {
//...
// add listener to room
room!!.addEventListener(roomEventListener)
}
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

