Best practices
These recommendations help you ship a reliable audio experience with the Video SDK for Android.
Permissions
The SDK cannot capture from the microphone until the user has granted the RECORD_AUDIO runtime permission. Request the permission before you call startAudio().
- Request
RECORD_AUDIOat the moment the user takes an action that needs audio (such as tapping a "Join audio" button), not at app launch. The prompt feels justified when it's tied to a clear action. - If the user denies the permission, surface a clear message and a path to retry. For example, link them to Android settings using
Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)so they can grant the permission outside the app. - If you also need video, request
CAMERAat the same time. - On Android 12 (API 31) and later, also request
BLUETOOTH_CONNECTif you want users to be able to use Bluetooth headsets. Without it, the SDK can still play audio through the device's earpiece and loudspeaker, but the OS will not route audio to a paired Bluetooth headset. Request it the first time the user joins audio.
See the Android permissions overview for the runtime-permission flow.
Enable audio with a clear action
Tie the call to startAudio() to a visible, user-initiated action like a "Join audio" or microphone button. This makes it easy for users to understand when they're connected to session audio and matches what they expect from native calling apps.
Show mute and talking status
- Render each user's mute state from their
ZoomVideoSDKAudioStatusso participants can see at a glance who is muted. Subscribe toonUserAudioStatusChangedand re-render when it fires. - Animate the microphone icon while a user is talking. Use the
onUserActiveAudioChangedcallback together withaudioStatus.isTalkingto drive the animation. This gives users confirmation that their mic is capturing their voice. - Highlight the active speaker in your video grid. For example by bordering their tile so participants can see who is currently speaking.
Audio routing
On phones, you control whether VoIP audio plays through the earpiece or the loudspeaker with setSpeaker.
- Default to the loudspeaker: for video-conferencing UX, since users typically hold the phone away from their face. Default to the earpiece for one-on-one calls held against the ear.
- Check
canSwitchSpeaker: before exposing a loudspeaker toggle in your UI. The SDK returnsfalsewhen a wired headset or Bluetooth headset has taken over the route — surface the connected device name instead of a toggle in that state. - Watch for headset connect and disconnect: Register a
BroadcastReceiverforIntent.ACTION_HEADSET_PLUGand the BluetoothAudioManager.ACTION_AUDIO_BECOMING_NOISYaction so you can update the UI when the user pulls out their earbuds mid-call.
Handle host-ask-unmute on the client
When the host calls unMuteAudio on a remote user, the target device receives onHostAskUnmute. Always show the user a confirmation prompt, never silently turn on their microphone. Calling unMuteAudio on mySelf without the user's explicit acknowledgment violates the user's expectation of mic privacy.
Lifecycle
-
The SDK keeps audio running while the Activity is paused (for example, when the user switches apps), so you typically should not call
stopAudio()inonPause(). Only stop audio when the user explicitly leaves the session. -
Keep audio-related state in a
ViewModelso configuration changes (rotation, theme change) don't tear down your audio UI alongside the Activity. -
Make sure your foreground service declaration covers
microphoneif you continue capturing audio while the app is in the background.Note
Android 14 and later require the
FOREGROUND_SERVICE_MICROPHONEpermission plus the matchingforegroundServiceTypeon your service.
Sound options
Leave original sound disabled unless your use case specifically needs unprocessed audio. The SDK's default audio processing (echo cancellation, noise suppression) produces a better experience for general voice communication. Enable original sound for music, broadcasting, or other content where the SDK's processing would degrade the source.
Permission changes mid-session
If the user disables the microphone permission while a session is running, audio capture silently stops. Listen for permission changes (or re-check RECORD_AUDIO when the Activity returns to the foreground) and surface a clear message asking the user to re-grant the permission and rejoin audio.