VideoSDK Class Methods - Android
initialize()
-
It starts the SDK for your app. Call it once, before any other SDK call, for example in
Application.onCreate(). Later calls do nothing. -
Until it has run,
createRoom(), the track factories andrunPreCallTest()throwIllegalStateException, andgetDevices(),getCameras()andgetMics()return empty lists.
Parameters
- context: Context
- Any context. The SDK keeps only its application context.
Returns
Unit
fun initialize(context: Context)
createRoom()
-
It creates a
Roomwith the settings you pass. Nothing is sent to the server until you calljoin()on the returned room. -
Only
roomIdandtokenare required. Pass the other arguments by name. -
VideoSDK.initialize()must have run first, or it throwsIllegalStateException. -
It throws
VideoSDKExceptionwith code3073(ERROR_INVALID_PARAMETER) ifroomIdortokenis empty. -
Only one room at a time: a second
createRoom()takes over from the first.
fun createRoom(
roomId: String,
token: String,
participantName: String? = null,
micEnabled: Boolean = true,
camEnabled: Boolean = true,
participantId: String? = null,
mode: Mode? = null,
multiStream: Boolean? = null,
customCameraTrack: CustomStreamTrack? = null,
customMicrophoneTrack: CustomStreamTrack? = null,
metaData: JSONObject? = null,
signalingBaseUrl: String? = null,
preferredProtocol: PreferredProtocol? = null,
codecSwitchEnabled: Boolean = true,
enableBatching: Boolean = true,
translationLanguage: String? = null,
speakingLanguage: String? = null,
maxResolution: MaxResolution? = null,
defaultCamera: FacingMode = FacingMode.front,
autoConsume: Boolean = true,
dynaCast: Boolean = false,
): Room
- See Creating a Room for every
createRoom()parameter.
getDevices()
-
The
getDevices()method returns the cameras and audio devices that are currently available: every camera first, then the audio devices, such as the speaker, the earpiece, a wired headset or a Bluetooth headset. -
The cameras are
CameraDeviceInfoentries, the same onesgetCameras()returns. The audio devices areMicrophoneDeviceInfoentries, the same onesgetMics()returns. -
It returns an empty list until
VideoSDK.initialize()has run. -
DeviceInfohas four properties:-
DeviceInfo.deviceId- Returns a string that identifies the device: the camera ID (for example
"0") for a camera, orSPEAKER_PHONE,EARPIECE,WIRED_HEADSETorBLUETOOTHfor an audio device.
- Returns a string that identifies the device: the camera ID (for example
-
DeviceInfo.label- Returns a string describing this device (for example
BLUETOOTHorCamera 1 (Front Camera)).
- Returns a string describing this device (for example
-
DeviceInfo.kind- Returns a
Kindvalue that is eitherKind.videoorKind.audio.
- Returns a
-
DeviceInfo.facingMode- Returns a value of type
FacingMode?indicating which way a camera faces (frontorback). It isnullfor audio devices and for cameras that face neither way, such as an external camera.
- Returns a value of type
-
Returns
List<DeviceInfo>
Example
val devices: List<DeviceInfo> = VideoSDK.getDevices()
for (device in devices) {
when (device) {
is CameraDeviceInfo -> Log.d("VideoSDK", "Camera ${device.deviceId}: ${device.label}, ${device.facingMode}")
is MicrophoneDeviceInfo -> Log.d("VideoSDK", "Audio device ${device.deviceId}: ${device.label}")
}
}
getCameras()
-
The
getCameras()method returns the cameras of the device, as a list ofCameraDeviceInfoobjects. -
It returns an empty list until
VideoSDK.initialize()has run. -
Pass a camera's
deviceIdtoroom.changeCam(), or ascameraIdtocreateCameraVideoTrack(). -
CameraDeviceInfohas four properties:-
CameraDeviceInfo.deviceId- Returns the camera ID, for example
"0"or"1".
- Returns the camera ID, for example
-
CameraDeviceInfo.label- Returns a string describing this camera (for example
Camera 1 (Front Camera)).
- Returns a string describing this camera (for example
-
CameraDeviceInfo.kind- Returns
Kind.video.
- Returns
-
CameraDeviceInfo.facingMode- Returns a value of type
FacingMode?indicating which way the camera faces (frontorback). It isnullfor a camera that faces neither way, such as an external camera.
- Returns a value of type
-
Returns
List<CameraDeviceInfo>
Example
val cameras: List<CameraDeviceInfo> = VideoSDK.getCameras()
for (camera in cameras) {
Log.d("VideoSDK", "Camera's DeviceId " + camera.deviceId)
Log.d("VideoSDK", "Camera's Label " + camera.label)
Log.d("VideoSDK", "Camera's Facing Mode " + camera.facingMode)
}
getMics()
-
The
getMics()method returns the audio devices that are currently available: the speaker, the earpiece, a wired headset or a Bluetooth headset. The method returns a list ofMicrophoneDeviceInfoobjects. -
These are the devices that play the call audio. Android has no separate list of microphones: switching to a wired or Bluetooth headset also switches to its microphone.
-
It returns an empty list until
VideoSDK.initialize()has run. -
Pass a device to
room.setAudioDevice(), or itsdeviceIdtoroom.changeMic()or asmicrophoneIdtocreateMicrophoneAudioTrack(). -
MicrophoneDeviceInfohas three properties:-
MicrophoneDeviceInfo.deviceId- Returns
SPEAKER_PHONE,EARPIECE,WIRED_HEADSETorBLUETOOTH.
- Returns
-
MicrophoneDeviceInfo.label- Returns a string describing this device (for example
BLUETOOTH).
- Returns a string describing this device (for example
-
MicrophoneDeviceInfo.kind- Returns
Kind.audio.
- Returns
-
Returns
List<MicrophoneDeviceInfo>
Example
val mics: List<MicrophoneDeviceInfo> = VideoSDK.getMics()
for (mic in mics) {
Log.d("VideoSDK", "Audio Device's DeviceId " + mic.deviceId)
Log.d("VideoSDK", "Audio Device's Label " + mic.label)
}
checkPermissions()
-
It checks the permissions you list and asks the user for any that are missing. When every permission is already granted, it shows nothing and calls
onGranted(). -
Call it before you create tracks or join a room. The track factories and
createRoom()never ask for permissions. -
Each
Permissionstands for these Android permissions, which your app must also declare in itsAndroidManifest.xml:Permission.audio:RECORD_AUDIOandMODIFY_AUDIO_SETTINGS.Permission.video:CAMERA.Permission.bluetooth:BLUETOOTH_CONNECTon Android 12 and later. On older versions it asks for nothing.
Parameters
-
context
- type:
Context REQUIRED- Pass an
Activity. Another context works only whenoptions.createNewTaskistrue.
- type:
-
permission
- type:
List<Permission> REQUIRED- The permission groups to request.
- type:
-
rationale
- type:
String? OPTIONAL- The explanation shown when the user has denied a permission before. If you don't pass one, the permissions are requested without a rationale dialog.
- type:
-
options
- type:
Permissions.Options? OPTIONAL- The options object for setting the titles and texts of the dialogs, such as the dialog that prompts users to manually grant permissions by navigating to device settings. If this parameter is not provided, the default titles and texts will be used. Its properties are
rationaleDialogTitle,settingsDialogTitle,settingsDialogMessage,settingsText,sendBlockedToSettingsandcreateNewTask.
- type:
-
permissionHandler
- type:
PermissionHandler REQUIRED- Tells you the outcome:
onGranted(),onDenied(),onBlocked()(the user chose "don't ask again" earlier) oronJustBlocked()(the user chose it during this request). - Return
truefromonBlocked()if you handle it yourself. The default,false, shows the SDK's dialog that sends the user to the app settings. onGranted()runs right away, on the calling thread, when every permission is already granted. The other callbacks run on the main thread.
- type:
Which dialogs the user sees
- The first request goes straight to the system prompt. The
rationaledialog appears only for a permission the user has denied before. - For a blocked permission, the SDK's go-to-settings dialog (
settingsDialogTitle,settingsDialogMessage,settingsText) appears only whenonBlocked()returnsfalse(the default) andoptions.sendBlockedToSettingsistrue(the default). - When the user comes back from Settings, the SDK checks again. A permission that is still blocked shows the dialog again.
If you skip rationale or options, pass the handler by name: VideoSDK.checkPermissions(this, permissionList, permissionHandler = permissionHandler).
Returns
Unit
Example
val permissionHandler: PermissionHandler = object : PermissionHandler() {
override fun onGranted() {}
override fun onBlocked(
context: Context,
blockedList: ArrayList<Permission>
): Boolean {
for (blockedPermission in blockedList) {
Log.d("VideoSDK Permission", "onBlocked: $blockedPermission")
}
return super.onBlocked(context, blockedList)
}
override fun onDenied(
context: Context,
deniedPermissions: ArrayList<Permission>
) {
for (deniedPermission in deniedPermissions) {
Log.d("VideoSDK Permission", "onDenied: $deniedPermission")
}
super.onDenied(context, deniedPermissions)
}
override fun onJustBlocked(
context: Context,
justBlockedList: ArrayList<Permission>,
deniedPermissions: ArrayList<Permission>
) {
for (justBlockedPermission in justBlockedList) {
Log.d("VideoSDK Permission", "onJustBlocked: $justBlockedPermission")
}
super.onJustBlocked(context, justBlockedList, deniedPermissions)
}
}
val permissionList: MutableList<Permission> = ArrayList()
permissionList.add(Permission.audio)
permissionList.add(Permission.video)
permissionList.add(Permission.bluetooth)
val rationale = "Please provide permissions"
val options = Permissions.Options().apply {
rationaleDialogTitle = "Info"
settingsDialogTitle = "Warning"
}
//If you wish to disable the dialog box that prompts
//users to manually grant permissions by navigating to device settings,
//you can set options.sendBlockedToSettings = false
VideoSDK.checkPermissions(this, permissionList, rationale, options, permissionHandler)
setSelectedVideoDevice()
-
It records which camera the SDK treats as the selected one, which
getSelectedVideoDevice()then returns. -
It doesn't open, close or switch a camera. To switch the camera in a room, call
room.changeCam(). To open a specific camera, pass itsdeviceIdascameraIdtocreateCameraVideoTrack().
Parameters
- selectedVideoDevice: CameraDeviceInfo
- Pass a camera from
getCameras().
- Pass a camera from
Returns
Unit
Example
val cameras: List<CameraDeviceInfo> = VideoSDK.getCameras()
val camera: CameraDeviceInfo = cameras[1]
VideoSDK.setSelectedVideoDevice(camera)
setProximityEnabled()
-
It lets the proximity sensor move the call audio to the earpiece while the user holds the phone to their ear, and back to the speaker when they move it away, as in a phone call. It is off by default.
-
A wired headset, a Bluetooth device, or a device you selected with
room.setAudioDevice()orroom.changeMic()keeps the audio. -
The SDK turns it off when you leave the room. It does nothing before
VideoSDK.initialize()has run.
Parameters
- enabled: Boolean
Returns
Unit
Example
VideoSDK.setProximityEnabled(true)
setMediaMode()
-
It sets Android's audio mode. The SDK switches to
AudioManager.MODE_IN_COMMUNICATIONwhenjoin()completes and back toAudioManager.MODE_NORMALwhen you leave, so most apps never call it. -
Call it after
join()returns, for example withMODE_NORMALfor a viewer that only plays an HLS stream. A mode you set before joining is replaced when the room starts.
Parameters
- mode: Int - an
AudioManager.MODE_*constant.
Returns
Unit
Example
VideoSDK.setMediaMode(AudioManager.MODE_NORMAL)
createCameraVideoTrack()
-
It creates a camera track and opens the camera. You can show it on your pre-call screen, pass it to
createRoom()ascustomCameraTrack, or publish it withroom.enableCam(track). -
It is a
suspendfunction: it returns once the camera is open, and throws if the camera can't be opened. You can call it from the main thread. Callstop()on the track to close the camera. -
Creating a new camera track ends an earlier camera track that is not published.
-
Refer to Custom Tracks for every parameter and the supported
encoderConfigvalues.
suspend fun createCameraVideoTrack(
encoderConfig: CustomCameraTrackConfig? = null,
facingMode: FacingMode? = null,
multiStream: Boolean = true,
cameraId: String? = null,
maxLayer: EncodingLayer? = null,
bitrateMode: BitrateMode? = null,
codec: VideoCodec? = null,
): CustomStreamTrack
Throws
IllegalStateExceptionifVideoSDK.initialize()has not run.VideoSDKException:3017if theCAMERApermission isn't granted,3021if the device has no camera,3071ifcameraIdmatches no camera,3053if the capture profile cannot be read,3023if another app is using the camera,3019if a device policy has disabled the camera, and3026if the camera fails to open for another reason.- These errors are not reported on
onError. A camera that fails after the track was created ends the track: setonEndedon the track to find out.
Example
lifecycleScope.launch {
try {
val cameraTrack = VideoSDK.createCameraVideoTrack(
encoderConfig = CustomCameraTrackConfig.H720P_W1280P,
facingMode = FacingMode.front,
)
} catch (e: VideoSDKException) {
Log.e("VideoSDK", "Camera track failed: ${e.code} ${e.name}")
}
}
createMicrophoneAudioTrack()
-
It creates a microphone track and opens the microphone. Pass it to
createRoom()ascustomMicrophoneTrack, or publish it withroom.unmuteMic(track). Nothing is sent until the track is published. Callstop()on the track to close the microphone. -
It is a
suspendfunction: it returns once the microphone is open, and throws if the microphone can't be opened. You can call it from the main thread. -
Refer to Custom Tracks for more examples.
suspend fun createMicrophoneAudioTrack(
encoderConfig: CustomMicrophoneTrackConfig? = null,
microphoneId: String? = null,
noiseConfig: NoiseConfig? = null,
): CustomStreamTrack
Parameters
-
encoderConfig
- type:
CustomMicrophoneTrackConfig? OPTIONAL- One of
SPEECH_LOW_QUALITY,SPEECH_STANDARD,MUSIC_STANDARD,STANDARD_STEREO,HIGH_QUALITYorHIGH_QUALITY_STEREO. - Default:
CustomMicrophoneTrackConfig.SPEECH_STANDARD
- type:
-
microphoneId
- type:
String? OPTIONAL- The
deviceIdof a device fromgetMics(). If it is not provided, the current device is used.
- type:
-
noiseConfig
- type:
NoiseConfig? OPTIONAL- Turns noise suppression, echo cancellation, automatic gain control and the high-pass filter on or off. If you pass a
NoiseConfig, a value you leave out takes its default:truefor the first three andfalseforhighPassFilter. If you don't pass one, theencoderConfigdecides.
- type:
Throws
IllegalStateExceptionifVideoSDK.initialize()has not run.VideoSDKException:3018if theRECORD_AUDIOpermission isn't granted,3022if the device has no microphone,3071ifmicrophoneIdmatches no device, and3024if the microphone can't be opened.- These errors are not reported on
onError. A microphone that fails after the track was created ends the track.
Example
lifecycleScope.launch {
try {
val micTrack = VideoSDK.createMicrophoneAudioTrack(
encoderConfig = CustomMicrophoneTrackConfig.HIGH_QUALITY,
noiseConfig = NoiseConfig(noiseSuppression = true, echoCancellation = true),
)
} catch (e: VideoSDKException) {
Log.e("VideoSDK", "Microphone track failed: ${e.code} ${e.name}")
}
}
createScreenShareVideoTrack()
-
It creates a screen share track from the consent
IntentthatMediaProjectionManagerreturns and returns it. Publish the track withroom.enableScreenShare(track). Screen capture starts only then. -
It returns
nullwhen the user declined the consent dialog (dataisnull), or whenencoderConfigis not a known profile. The second case also reports3071(ERROR_INVALID_CUSTOM_TRACK_CONFIG) ononErrorwhile you are in a room. -
withAudio = truealso captures the audio playing on the device and mixes it into your microphone track, so muting the microphone mutes both. No separateSHARE_AUDIOstream is sent, so other participants hear it in your microphone stream andgetShareAudioStats()returnsnullfor you. It needs Android 10 (API 29) or later and theRECORD_AUDIOpermission. -
Refer to Custom Tracks for the supported
encoderConfigvalues.
fun createScreenShareVideoTrack(
encoderConfig: String? = null,
data: Intent?,
multiStream: Boolean = false,
withAudio: Boolean = false,
): CustomStreamTrack?
Example
val track = VideoSDK.createScreenShareVideoTrack(
encoderConfig = "h720p_15fps",
data = data,
withAudio = true,
)
if (track != null) {
lifecycleScope.launch {
try {
room.enableScreenShare(track)
} catch (e: VideoSDKException) {
Log.e("VideoSDK", "Screen share failed: ${e.code} ${e.name}")
}
}
}
runPreCallTest()
-
It runs a pre-call test: it checks the camera and the microphone, then measures the network by sending media to a test server, and scores the uplink and the downlink. It doesn't need a room.
-
It is a
suspendfunction: it returns thePreCallTestResultwhen the test finishes, or throwsPreCallTestExceptionwhen the test fails. Cancelling the coroutine stops the test, and so doesstopPreCallTest(). -
onStatsChangeruns on the main thread each time the test samples the network. -
VideoSDK.initialize()must have run first, or it throwsIllegalStateException. The test doesn't ask for theCAMERAorRECORD_AUDIOpermissions: request them first withcheckPermissions(). -
Without a
videoTrackoraudioTrackin the options, the test opens the devices itself. After a test that succeeds, those tracks stay open and are yours: they areresult.camera?.trackandresult.microphone?.track, so stop them or publish them. Tracks you passed in are never stopped. -
A test can't start after
createRoom()until that room is left. Joining a room stops a running test. -
Refer to Precall Setup for the options, the result and the error codes.
suspend fun runPreCallTest(
options: PreCallTestOptions,
onStatsChange: ((PreCallNetworkQuality) -> Unit)? = null,
): PreCallTestResult
Parameters
-
options
- type:
PreCallTestOptions REQUIRED- The test settings:
tokenis required, andsamplingDuration,audioOnly,videoTrack,audioTrack,videoConfigandaudioConfigare optional.
- type:
-
onStatsChange
- type:
((PreCallNetworkQuality) -> Unit)? OPTIONAL- Receives each network sample while the test runs.
- type:
Returns
PreCallTestResult
Throws
PreCallTestExceptionwhen the test fails. Itscodenames the reason, for exampleERROR_PRECALL_INVALID_CONFIGorERROR_PRECALL_TEST_ALREADY_RUNNING.IllegalStateExceptionifVideoSDK.initialize()has not run.
Example
lifecycleScope.launch {
try {
val result = VideoSDK.runPreCallTest(PreCallTestOptions(token = token)) { stats ->
Log.d("VideoSDK", "Uplink quality: ${stats.uplink?.quality}")
}
Log.d("VideoSDK", "Camera works: ${result.camera?.status}")
Log.d("VideoSDK", "Downlink quality: ${result.networkQuality?.downlink?.quality}")
} catch (e: PreCallTestException) {
Log.e("VideoSDK", "Pre-call test failed: ${e.code} ${e.message}")
}
}
stopPreCallTest()
-
It stops the running pre-call test, if there is one. It returns at once.
-
The test still reports its outcome once:
runPreCallTest()returns a result whoseabortedistrue, with whatever was measured until then, or throwsPreCallTestExceptionif the test was already failing.
Returns
Unit
Example
VideoSDK.stopPreCallTest()
setVideoEffects()
-
It sets the camera effects: auto-framing, low-light correction, a stylised look and a colour grade. Call it before you join; the effects apply when the camera starts. In a room, use
room.setVideoEffects()instead. -
Effects run on the GPU with
pipeline = VideoEffectsConfig.Pipeline.GRAPH. If the graph can't start on the device,onErrorreports3080(ERROR_VIDEO_EFFECTS_GRAPH_UNAVAILABLE) once, and the camera stays onPipeline.LEGACY: the call keeps going, but the video is sent without effects. AGRAPHrequest made before any camera has started is not an error. Readappliedandreasonin the returned value, or callgetAppliedVideoEffectsConfig(), to find out what is running. -
Before any camera has started, a
GRAPHrequest returnsappliedfalsewith areasonthat starts withpending:. It is kept, and the next camera start runs it.
Parameters
-
config
- type:
VideoEffectsConfig REQUIREDpipeline:Pipeline.LEGACY(the default, no effects) orPipeline.GRAPH.framing:Framing(enabled, maxZoom). Crops and zooms to keep the subject you publish withpublishFramingSubject()in the centre.lighting:Lighting(enabled, strength). Brightens dark parts of the picture.style:Style(preset, strength, levels), with the presetStylePreset.OFF,POSTERIZEorVIVID.filter:Filter(lut, strength), with the gradeLut.OFF,WARM,COOLorMONO.- Every effect is off unless you turn it on.
- type:
Returns
JSONObject- The configuration the SDK applied, withapplied(falsewhen the request can't be honoured) andreason.
Example
val applied: JSONObject = VideoSDK.setVideoEffects(
VideoEffectsConfig(
pipeline = VideoEffectsConfig.Pipeline.GRAPH,
lighting = VideoEffectsConfig.Lighting(enabled = true),
filter = VideoEffectsConfig.Filter(lut = VideoEffectsConfig.Lut.WARM),
)
)
Log.d("VideoSDK", "Video effects: $applied")
getAppliedVideoEffectsConfig()
- It returns the camera effects configuration in force, which can differ from what you asked for. A
GRAPHrequest the device can't run reportsappliedasfalsewith areason, and the video is sent without effects.
Returns
JSONObject
Example
val config: JSONObject = VideoSDK.getAppliedVideoEffectsConfig()
if (!config.optBoolean("applied")) {
Log.w("VideoSDK", "GPU effects not applied: ${config.optString("reason")}")
}
publishFramingSubject()
-
It tells auto-framing where the subject is, as a box measured in fractions of the frame, from
0.0to1.0. Auto-framing must be on:VideoEffectsConfig.Framing(enabled = true)withPipeline.GRAPH, set withsetVideoEffects(). -
The SDK has no face detector of its own. Run your detector and call this for every box it finds. Until you publish a box, the video is sent unchanged.
-
A
widthorheightof0or less means there is no subject, and the picture eases back to the full frame. -
You can call it from any thread.
Parameters
- cx: Float - the subject's centre, across the frame.
- cy: Float - the subject's centre, down the frame.
- width: Float - the subject's width, as a fraction of the frame width.
- height: Float - the subject's height, as a fraction of the frame height.
Returns
Unit
Example
// a face your detector found in the upper middle of the frame
VideoSDK.publishFramingSubject(cx = 0.5f, cy = 0.4f, width = 0.25f, height = 0.35f)
setScreenFlash()
-
It sets how the user's face is lit when
participant.captureImage()runs withCaptureFlash.ONon a front camera that has no flash. -
Pass
ScreenFlash.whiteOverlay(activity)for a white screen at full brightness, your ownScreenFlashimplementation for a custom UI, ornullto capture without light. Theshow()andhide()methods of aScreenFlashare called on the main thread, andhide()is called even when the capture fails.
Parameters
- flash: ScreenFlash?
Returns
Unit
Example
VideoSDK.setScreenFlash(ScreenFlash.whiteOverlay(this))
setKeyProvider()
-
It turns on end-to-end encryption with the keys in the provider. Call it before
room.join(); a provider set later doesn't encrypt a room that is already running. -
A shared key, set with
setSharedKey()on the provider, covers the whole room. Keys set per participant withsetParticipantKey()apply only when there is no shared key. -
To turn encryption off, call
removeKeyProvider(). -
Refer to End-to-End Encryption for more details.
Parameters
- provider: BaseKeyProvider
Returns
Unit
Example
val baseKeyProvider = BaseKeyProvider()
baseKeyProvider.setSharedKey("your-shared-key")
VideoSDK.setKeyProvider(baseKeyProvider)
removeKeyProvider()
- It turns end-to-end encryption off and forgets the provider set with
setKeyProvider(). Call it beforeroom.join().
Returns
Unit
Example
VideoSDK.removeKeyProvider()
getKeyProvider()
- It returns the provider set with
setKeyProvider(), ornullif none is set.
Returns
BaseKeyProvider?
Example
val encrypted = VideoSDK.getKeyProvider() != null
setParticipantKey()
-
It sets or changes one participant's encryption key, also while the room is running.
-
Set a key provider with
setKeyProvider()first. Without one, it throwsVideoSDKExceptionwith3073(ERROR_INVALID_PARAMETER). -
Pass
nullas the key to remove the participant's key. This device then stops decrypting that participant until a new key is set. -
It has no effect while a shared key is set.
-
A key lasts for the current room only. When a participant leaves, their key is removed. When you leave the room, every participant key is removed, so set them again after each
join(). A reconnect in the same room keeps them.
Parameters
- participantId: String
- key: String?
Returns
Unit
Example
private val roomEventListener = object : RoomEventListener() {
override fun onParticipantJoined(participant: Participant) {
// the participant's key from your server
VideoSDK.setParticipantKey(participant.id, keyFor(participant.id))
}
}
removeKey()
- A method of your
KeyProvider(BaseKeyProvider), not ofVideoSDK. It removes one participant's key. - On the provider you passed to
setKeyProvider(), it does the same assetParticipantKey(participantId, null): this device stops decrypting that participant until a new key is set. - On any other provider it only forgets the stored key. A participant with no key is ignored.
Parameters
- participantId: String
Returns
Unit
Example
private val roomEventListener = object : RoomEventListener() {
override fun onParticipantLeft(participant: Participant, reason: LeaveReason) {
keyProvider.removeKey(participant.id)
}
}
setActivityForLifeCycle()
-
By default, the SDK turns the local camera off about half a second after your app goes to the background, and turns it back on with the same settings when the app returns. A camera you turned off yourself stays off. Other participants get
onStreamDisabledandonStreamEnabledfor your video. The microphone is left on. -
It reacts to every activity of your app, not only to your call screen.
-
The SDK runs no foreground service. On Android 15 and later, a backgrounded app loses its network and the call drops within seconds unless your app runs its own camera or microphone foreground service. See Background Handling.
-
Pass your call activity so that the SDK reacts only to that activity. The SDK drops the reference when the activity is destroyed.
Parameters
- activity: Activity
Returns
Unit
Example
VideoSDK.setActivityForLifeCycle(this)
setEnableActivityLifecycle()
-
It turns the automatic camera handling described in
setActivityForLifeCycle()on or off. It is on by default. -
Pass
falseto keep the camera on while the app is in the background, for example in picture-in-picture mode.
Parameters
- enableActivityLifecycle: Boolean
Returns
Unit
Example
VideoSDK.setEnableActivityLifecycle(false)
setLogLevel()
-
It sets how much the SDK writes to Logcat. It applies to the whole app at once. The level is
LogLevel.INFOuntil you set one. -
Each level includes the levels before it:
LogLevel.NONE: nothing.LogLevel.ERROR: failures that stopped something, such as a failed join.LogLevel.WARN: adds problems that didn't stop anything, such as low bandwidth.LogLevel.INFO: adds milestones, such as joining and leaving.LogLevel.DEBUG: adds details that help while you build. Too noisy for release builds.LogLevel.ALL: adds frequent events, such as active speaker changes and per-second statistics.
Parameters
- level: LogLevel
- Default:
LogLevel.INFO
- Default:
Returns
Unit
Example
VideoSDK.setLogLevel(LogLevel.DEBUG)
getLogLevel()
- It returns the level set with
setLogLevel(), orLogLevel.INFOif you haven't set one.
Returns
LogLevel
Example
val level: LogLevel = VideoSDK.getLogLevel()
disableTelemetry()
- It stops sending telemetry to VideoSDK. Telemetry is on when the app starts. Once you turn it off, it stays off until the app process ends.
Returns
Unit
Example
VideoSDK.disableTelemetry()
enableTelemetry()
- Telemetry is already on when the app starts, so you don't need to call it. It doesn't turn telemetry back on after
disableTelemetry(): it only changes whatisTelemetryEnabled()returns.
Returns
Unit
isTelemetryEnabled()
- It returns whether telemetry is on:
trueuntil you calldisableTelemetry().
Returns
Boolean
getErrorCodes()
-
It returns a
JSONObjectthat maps every error name to its code, for exampleINVALID_TOKENto4002. -
Use it to look up a code by name. You can also pass a
codetoVideoSDKError.fromCode(code)to get the matchingVideoSDKError. -
Refer to Error Codes for the list.
Returns
JSONObject
Example
val errorCodes: JSONObject = VideoSDK.getErrorCodes()
val invalidToken = errorCodes.optInt("INVALID_TOKEN") // 4002
Got a Question? Ask us on discord

