Skip to main content
Version: 3.x.x

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.
  • switchRoomId is the ID of the room you switched to with switchTo(). It is null on 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.
  • reason is a LeaveReason that tells you why, for example MANUAL_LEAVE_CALLED after leave().

onSpeakerChanged​

  • This event is triggered when the active speaker in the room gets changed.
  • activeSpeakerId is null when 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.
  • presenterId is null when 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