# 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_AUDIO` at 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 `CAMERA` at the same time. - **On Android 12 (API 31) and later, also request `BLUETOOTH_CONNECT`** if 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](https://developer.android.com/guide/topics/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 `ZoomVideoSDKAudioStatus` so participants can see at a glance who is muted. Subscribe to [`onUserAudioStatusChanged`](/docs/video-sdk/android/audio/audio-events/) and re-render when it fires. - Animate the microphone icon while a user is talking. Use the [`onUserActiveAudioChanged`](/docs/video-sdk/android/audio/audio-events/) callback together with `audioStatus.isTalking` to 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`](/docs/video-sdk/android/audio/#route-audio-between-the-earpiece-and-loudspeaker). - **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`](/docs/video-sdk/android/audio/#route-audio-between-the-earpiece-and-loudspeaker)**: before exposing a loudspeaker toggle in your UI. The SDK returns `false` when 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 [`BroadcastReceiver`](https://developer.android.com/develop/connectivity/bluetooth/transfer-data) for `Intent.ACTION_HEADSET_PLUG` and the Bluetooth `AudioManager.ACTION_AUDIO_BECOMING_NOISY` action 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`](/docs/video-sdk/android/audio/host-controls/#ask-a-single-user-to-unmute). 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()` in `onPause()`. Only stop audio when the user explicitly leaves the session. - Keep audio-related state in a `ViewModel` so configuration changes (rotation, theme change) don't tear down your audio UI alongside the Activity. - Make sure your foreground service declaration covers `microphone` if you continue capturing audio while the app is in the background. > **Note** > > Android 14 and later require the `FOREGROUND_SERVICE_MICROPHONE` permission plus the matching `foregroundServiceType` on your service. ## Sound options Leave [original sound](/docs/video-sdk/android/audio/sound-options/) 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.