Core features

The Video SDK for Android lets users speak and hear each other in a session over VoIP using their device's microphone and speaker. Users who can't connect over VoIP can dial in by phone — see Phone (PSTN).

The core controls let you connect to audio, mute and unmute, disconnect, and route between the earpiece and loudspeaker. For host-only controls, see Host audio controls. To let users test their microphone and speaker before joining a session, see Preview.

The ZoomVideoSDKAudioHelper provides the methods used to manage a user's audio. Before changing any audio state, check whether the user is already connected to audio.

val audioStatus = user.audioStatus
val audioType = audioStatus.audioType
val audioHelper = ZoomVideoSDK.getInstance().audioHelper
ZoomVideoSDKAudioStatus audioStatus = user.getAudioStatus();
ZoomVideoSDKAudioStatus.ZoomVideoSDKAudioType audioType = audioStatus.getAudioType();
ZoomVideoSDKAudioHelper audioHelper = ZoomVideoSDK.getInstance().getAudioHelper();

audioType is one of the values defined on ZoomVideoSDKAudioStatus.ZoomVideoSDKAudioType.

ValueMeaning
ZoomVideoSDKAudioType_NoneThe user is not connected to session audio.
ZoomVideoSDKAudioType_VOIPThe user is connected over VoIP (microphone and speaker).
ZoomVideoSDKAudioType_TELEPHONYThe user is connected by phone dial-in. See Phone (PSTN).

Connect to audio

The SDK can't capture from the microphone until the user grants the RECORD_AUDIO runtime permission. Request it when the user takes an action that needs audio (a "Join audio" button is the conventional pattern), then call startAudio() on the ZoomVideoSDKAudioHelper.

private val audioPermission = registerForActivityResult(
    ActivityResultContracts.RequestPermission()
) { granted ->
    if (granted) {
        ZoomVideoSDK.getInstance().audioHelper.startAudio()
    } else {
        // Surface a message asking the user to grant the permission.
    }
}
fun onJoinAudioClicked() {
    audioPermission.launch(Manifest.permission.RECORD_AUDIO)
}
private final ActivityResultLauncher<String> audioPermission =
    registerForActivityResult(new ActivityResultContracts.RequestPermission(), granted -> {
        if (Boolean.TRUE.equals(granted)) {
            ZoomVideoSDK.getInstance().getAudioHelper().startAudio();
        } else {
            // Surface a message asking the user to grant the permission.
        }
    });
void onJoinAudioClicked() {
    audioPermission.launch(Manifest.permission.RECORD_AUDIO);
}

Required Android permission

RECORD_AUDIO. See the Android permissions overview and the Best practices topic for the full permission flow, including Bluetooth on Android 12+.

If the user might already be connected (for example, they joined audio earlier), check audioType before starting so you don't reconnect unnecessarily.

if (audioType == ZoomVideoSDKAudioStatus.ZoomVideoSDKAudioType.ZoomVideoSDKAudioType_None) {
    audioHelper.startAudio()
} else {
    // The user is already connected to audio.
}
if (audioType == ZoomVideoSDKAudioStatus.ZoomVideoSDKAudioType.ZoomVideoSDKAudioType_None) {
    audioHelper.startAudio();
} else {
    // The user is already connected to audio.
}

Mute and unmute a user

Mute the local user (or any user, if the local user is the host) by calling muteAudio with the associated ZoomVideoSDKUser.

audioHelper.muteAudio(user)
audioHelper.muteAudio(user);

Unmute in the same way with unMuteAudio.

audioHelper.unMuteAudio(user)
audioHelper.unMuteAudio(user);

Disconnect from audio

To leave the audio portion of the session entirely, call stopAudio. Use this only when the user explicitly disconnects. To silence the user temporarily, use muteAudio instead.

if (audioType == ZoomVideoSDKAudioStatus.ZoomVideoSDKAudioType.ZoomVideoSDKAudioType_VOIP) {
    audioHelper.stopAudio()
}
if (audioType == ZoomVideoSDKAudioStatus.ZoomVideoSDKAudioType.ZoomVideoSDKAudioType_VOIP) {
    audioHelper.stopAudio();
}

Route audio between the earpiece and loudspeaker

On Android, the SDK can route VoIP audio through either the device's earpiece, default for in-call audio, or its loudspeaker. Use setSpeaker to toggle between them.

// Route audio through the loudspeaker.
audioHelper.setSpeaker(true)
// Route audio through the earpiece.
audioHelper.setSpeaker(false)
// Route audio through the loudspeaker.
audioHelper.setSpeaker(true);
// Route audio through the earpiece.
audioHelper.setSpeaker(false);

Use getSpeakerStatus to read the current routing and canSwitchSpeaker to check whether the device permits switching For example, the SDK returns false when a wired headset or Bluetooth audio device is connected and the OS owns the route.

if (audioHelper.canSwitchSpeaker()) {
    val onLoudspeaker = audioHelper.speakerStatus
    audioHelper.setSpeaker(!onLoudspeaker)
}
if (audioHelper.canSwitchSpeaker()) {
    boolean onLoudspeaker = audioHelper.getSpeakerStatus();
    audioHelper.setSpeaker(!onLoudspeaker);
}

When the local user is the session host, they can also mute participants, request a participant unmute, and mute everyone at once. For more information, see Host audio controls.