Listen for Callback Events

The ZoomVideoSDKDelegate allows you to subscribe to callback events that provide status updates on the operations performed in your app that are related to the Video SDK. For example, you might want to be notified when a user has successfully joined or left a session.

On This Page

Implement a Listener

To subscribe to these events, you must define your own instance of the ZoomVideoSDKDelegate object and you must add it to the SDK by calling the addListener function. In this section, we will show you how to implement this listener and assign it to the SDK instance and also provide you with examples of the event handlers associated with the SDK.

Add a Listener


ZoomVideoSDK.getInstance().addListener(listener);

ZoomVideoSDK.getInstance().addListener(listener)

Example Implementation of the Listener


ZoomVideoSDKDelegate listener = new ZoomVideoSDKDelegate() {
    @Override
    public void onSessionPasswordWrong(ZoomVideoSDKPasswordHandler handler) {
        // Recommended action: prompt user to enter password again and pass user input into
        // handler.inputSessionPassword
        handler.inputSessionPassword(“stringFromUserInput”);
        // Alternatively, you may abandon the attempt to join the session
        handler.leaveSessionIgnorePassword();
    }

val listener = object : ZoomVideoSDKDelegate {
// You can use any of the available event callbacks here based on your use case.
// Example - To listen for when a user enters a wrong password while attempting to join a session, use the onSessionPasswordWrong() callback function
    override fun onSessionPasswordWrong(handler: ZoomVideoSDKPasswordHandler?) {
        // Recommended action: prompt user to enter password again and pass user input into
        // handler.inputSessionPassword
        handler?.inputSessionPassword(“stringFromUserInput”)
        // Alternatively, you may abandon the attempt to join the session
        handler?.leaveSessionIgnorePassword()
    }

Callback Functions

The following examples show a list of callback functions that are provided by the Video SDK. You can use these functions and implement any additional operations as needed after receiving the result of the callback function.


@Override
public void onError(int errorCode) {
    // See error code documentation
}

override fun onError(errorCode: Int) {
// See error code documentation
}

Get notified when users join a session


@Override
public void onUserJoin(ZoomVideoSDKUserHelper userHelper, List<ZoomVideoSDKUser> userList) {
    for (ZoomVideoSDKUser user : userList) {
        // Access user info for each user that has joined
    }
}

override fun onUserJoin(userHelper: ZoomVideoSDKUserHelper?, userList: MutableList<ZoomVideoSDKUser>) {
    userList.forEach {
        // Access user info for each user that has joined
    }
}

Get notified when users leave a session


@Override
public void onUserLeave(ZoomVideoSDKUserHelper userHelper, List<ZoomVideoSDKUser> userList) {
    for (ZoomVideoSDKUser user : list) {
        // Access user info for each user that has left
    }
}

override fun onUserLeave(userHelper: ZoomVideoSDKUserHelper?, userList: MutableList<ZoomVideoSDKUser>) {
    userList.forEach {
        // Access user info for each user that has left
    }
}

Get notified when a user's video status has changed


@Override
public void onUserVideoStatusChanged(List<ZoomVideoSDKUser> userList) {
    for (ZoomVideoSDKUser user : userList) {
        // Check if the current user's video is on
        ZoomVideoSDKUserInfo userInfo = userHelper.getUserInfo(userId);
    ZoomVideoSDKVideoStatus videoStatus = user.getVideoStatus();
    videoStatus.isOn();
    }
}

override fun onUserVideoStatusChanged(videoHelper: ZoomVideoSDKVideoHelper?, userList: MutableList<ZoomVideoSDKUser>) {
    userList.forEach {
        // Check if the current user's video is on
        val videoStatus = it.videoStatus
        videoStatus.isOn
    }
}

Get notified when a user's audio status has changed


@Override
public void onUserAudioStatusChanged(ZoomVideoSDKAudioHelper audioHelper, List<ZoomVideoSDKUser> userList) {
    for (ZoomVideoSDKUser user : userList) {
        // Check the current user to see if they are muted
        ZoomVideoSDKAudioStatus audioStatus = user.getAudioStatus();
        audioStatus.isMuted();
    }
}

override fun onUserAudioStatusChanged(audioHelper: ZoomVideoSDKAudioHelper?, userList: MutableList<ZoomVideoSDKUser>) {
    userList.forEach {
        // Check the current user to see if they are muted
        val audioStatus = it.audioStatus
        audioStatus.isMuted
    }
}

Get notified when screen sharing status changes


@Override
public void onUserShareStatusChanged(ZoomVideoSDKShareHelper shareHelper, ZoomVideoSDKUser userInfo, ZoomVideoSDKShareStatus status) {
    switch (status) {
        case ZoomVideoSDKShareStatus_Resume:
        case ZoomVideoSDKShareStatus_Start:
            // The user with the corresponding userInfo is now sharing
            break;
        case ZoomVideoSDKShareStatus_Pause:
        case ZoomVideoSDKShareStatus_Stop:
            // The user with the corresponding userInfo is not sharing
            break;
    }
}

override fun onUserShareStatusChanged(shareHelper: ZoomVideoSDKShareHelper?, userInfo: ZoomVideoSDKUser?, status: ZoomVideoSDKShareStatus?) {
    when (status) {
        ZoomVideoSDKShareStatus.ZoomVideoSDKShareStatus_Start,
        ZoomVideoSDKShareStatus.ZoomVideoSDKShareStatus_Resume -> {
            // The user with the corresponding userInfo is now sharing
        }
        ZoomVideoSDKShareStatus.ZoomVideoSDKShareStatus_Pause,
        ZoomVideoSDKShareStatus.ZoomVideoSDKShareStatus_Stop -> {
            // The user with the corresponding userInfo is not sharing
        }
    }
}

Get notified when the status of a live stream changes


@Override
public void onLiveStreamStatusChanged(ZoomVideoSDKLiveStreamStatus status) {
    // See live stream documentation
}

override fun onLiveStreamStatusChanged(status: ZoomVideoSDKLiveStreamStatus) {
    // See live stream documentation
}

Get notified when a message is posted


@Override
public void onChatNewMessageNotify(ZoomVideoSDKChatHelper chatHelper, ZoomVideoSDKChatMessage messageItem) {
    String content = messageItem.getContent();
    ZoomVideoSDKUser sender = messageItem.getSenderUser();
}

override fun onChatNewMessageNotify(chatHelper: ZoomVideoSDKChatHelper?, messageItem: ZoomVideoSDKChatMessage) {
    val content = messageItem.content
    val sender = messageItem.senderUser
}

Get notified when the host of the session is changed


@Override
public void onUserHostChanged(ZoomVideoSDKUserHelper userHelper, ZoomVideoSDKUser userInfo) {
    // Recommended action: check if current user is the new host and update UI if applicable
}

override fun onUserHostChanged(userHelper: ZoomVideoSDKUserHelper?, userInfo: ZoomVideoSDKUser?) {
    // Recommended action: check if current user is the new host and update UI if applicable
}

Get notified when active audio changes


@Override
public void onUserActiveAudioChanged(ZoomVideoSDKAudioHelper audioHelper, List<ZoomVideoSDKUser> list) {
    for (ZoomVideoSDKUser user : list) {
        // Check if the current user is talking
        ZoomVideoSDKAudioStatus audioStatus = user.getAudioStatus();
        audioStatus.isTalking();
    }
}

override fun onUserActiveAudioChanged(audioHelper: ZoomVideoSDKAudioHelper?, list: MutableList<ZoomVideoSDKUser>) {
    list.forEach {
        // Check if the current user is talking
        val audioStatus = it.audioStatus
        audioStatus.isTalking
    }
}

Get notified when a user attempts to join a session without entering a required password


@Override
public void onSessionNeedPassword(ZoomVideoSDKPasswordHandler handler) {
    // Try entering the password again
    handler.inputSessionPassword("anotherPassword");
    // Leave the session without trying
    handler.leaveSessionIgnorePassword();
}

override fun onSessionNeedPassword(handler: ZoomVideoSDKPasswordHandler?) {
    // Try entering password again
    handler?.inputSessionPassword("anotherPassword")
    // Leave the session without trying
    handler?.leaveSessionIgnorePassword()
}

Get notified when a user enters an incorrect password while attempting to join a session


@Override
public void onSessionPasswordWrong(ZoomVideoSDKPasswordHandler handler) {
    // Try entering the password again
    handler.inputSessionPassword("anotherPassword");
    // Leave the session without trying
    handler.leaveSessionIgnorePassword();
}

override fun onSessionPasswordWrong(handler: ZoomVideoSDKPasswordHandler?) {
    // Try entering password again
    handler?.inputSessionPassword("anotherPassword")
    // Leave the session without trying
    handler?.leaveSessionIgnorePassword()
}

Get notified when you have successfully joined the session


@Override
public void onSessionJoin() {
    // You have successfully joined the session
}

override fun onSessionJoin() {
    // You have successfully joined the session
}

Get notified when you have successfully left the session


@Override
public void onSessionLeave() {
    // You have successfully left the session
}

override fun onSessionLeave() {
    // You have successfully left the session
}

Get notified when the current user is the new host


@Override
public void onUserManagerChanged(ZoomVideoSDKUser zoomVideoSDKUser) {
    // Recommended action: check if current user is the new host and update UI if applicable
}

override fun onUserManagerChanged(user: ZoomVideoSDKUser) {
    // Recommended action: check if current user is the new host and update UI if applicable
}

Get notified when the user name changed


@Override
public void onUserNameChanged(ZoomVideoSDKUser zoomVideoSDKUser) {
    // Recommended action: get new username and update UI if applicable
}

override fun onUserNameChanged(user: ZoomVideoSDKUser) {
    // Recommended action: get new username and update UI if applicable
}

Get notified when mixed audio raw data is received


@Override
public void onMixedAudioRawDataReceived(ZoomVideoSDKAudioRawData zoomVideoSDKAudioRawData) {
    // See raw data documentation for more information
}

override fun onMixedAudioRawDataReceived(rawData: ZoomVideoSDKAudioRawData?) {
    // See raw data documentation for more information
}

Get notified when one-way audio raw data is received


@Override
public void onOneWayAudioRawDataReceived(ZoomVideoSDKAudioRawData zoomVideoSDKAudioRawData, ZoomVideoSDKUser zoomVideoSDKUser) {
    // See raw data documentation for more information
}

override fun onOneWayAudioRawDataReceived(rawData: ZoomVideoSDKAudioRawData?, user: ZoomVideoSDKUser?) {
    // See raw data documentation for more information
}

Get notified when shared audio raw data is received


@Override
public void onShareAudioRawDataReceived(ZoomVideoSDKAudioRawData zoomVideoSDKAudioRawData) {
    // See raw data documentation for more information
}

override fun onShareAudioRawDataReceived(rawData: ZoomVideoSDKAudioRawData?) {
    // See raw data documentation for more information
}

Need help?

If you're looking for help, try Developer Support or our Developer Forum. Priority support is also available with Premier Developer Support plans.