Skip to main content
The Android SDK provides coroutine-native APIs and Kotlin Flow for text streaming, and a full WebRTC voice pipeline with AudioManager integration. The underlying WebRTC protocol is described in the WebRTC connection guide — this page covers the Android-specific implementation.
During development, initialise the client with an hk_test_… sandbox credential instead of hk_live_…. There is no separate sandbox mode or URL — sandbox behavior comes entirely from the credential prefix. No AI credits are consumed and no usage is billed. See Sandbox mode.

Install

Add the dependency to your build.gradle.kts:
Add permissions to AndroidManifest.xml:
RECORD_AUDIO is a dangerous permission — it must be requested at runtime before starting a voice session. The SDK throws MicrophonePermissionException if the permission is absent. See the Requesting microphone permission at runtime accordion below.

Text and streaming

Open a session, send a message, and close in a try/finally block to ensure cleanup.

Voice session


Requesting microphone permission at runtime

Use the Compose rememberLauncherForActivityResult pattern to request RECORD_AUDIO before starting a voice session:

Handling audio focus

Request audio focus before starting the voice session so your app ducks music apps and receives focus-change events (e.g., when a call arrives):
Call requestAudioFocus() before voiceSession.start() and abandonAudioFocus() after voiceSession.stop().

Bluetooth headset support

To route audio through a paired Bluetooth headset, enable Bluetooth SCO before starting the voice session:
Add the additional manifest permission:
And call enableBluetoothSco(context) after audioManager.mode = AudioManager.MODE_IN_COMMUNICATION, before voiceSession.start().

Never hard-code your credential. Read it from an environment variable: