Skip to main content
Version: 3.x.x

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 and runPreCallTest() throw IllegalStateException, and getDevices(), getCameras() and getMics() return empty lists.

Parameters​

  • context: Context
    • Any context. The SDK keeps only its application context.

Returns​

  • Unit
initialize
fun initialize(context: Context)

createRoom()​

  • It creates a Room with the settings you pass. Nothing is sent to the server until you call join() on the returned room.

  • Only roomId and token are required. Pass the other arguments by name.

  • VideoSDK.initialize() must have run first, or it throws IllegalStateException.

  • It throws VideoSDKException with code 3073 (ERROR_INVALID_PARAMETER) if roomId or token is empty.

  • Only one room at a time: a second createRoom() takes over from the first.

createRoom
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

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 CameraDeviceInfo entries, the same ones getCameras() returns. The audio devices are MicrophoneDeviceInfo entries, the same ones getMics() returns.

  • It returns an empty list until VideoSDK.initialize() has run.

  • DeviceInfo has four properties:

    1. DeviceInfo.deviceId

      • Returns a string that identifies the device: the camera ID (for example "0") for a camera, or SPEAKER_PHONE, EARPIECE, WIRED_HEADSET or BLUETOOTH for an audio device.
    2. DeviceInfo.label

      • Returns a string describing this device (for example BLUETOOTH or Camera 1 (Front Camera)).
    3. DeviceInfo.kind

      • Returns a Kind value that is either Kind.video or Kind.audio.
    4. DeviceInfo.facingMode

      • Returns a value of type FacingMode? indicating which way a camera faces (front or back). It is null for audio devices and for cameras that face neither way, such as an external camera.

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 of CameraDeviceInfo objects.

  • It returns an empty list until VideoSDK.initialize() has run.

  • Pass a camera's deviceId to room.changeCam(), or as cameraId to createCameraVideoTrack().

  • CameraDeviceInfo has four properties:

    1. CameraDeviceInfo.deviceId

      • Returns the camera ID, for example "0" or "1".
    2. CameraDeviceInfo.label

      • Returns a string describing this camera (for example Camera 1 (Front Camera)).
    3. CameraDeviceInfo.kind

      • Returns Kind.video.
    4. CameraDeviceInfo.facingMode

      • Returns a value of type FacingMode? indicating which way the camera faces (front or back). It is null for a camera that faces neither way, such as an external camera.

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 of MicrophoneDeviceInfo objects.

  • 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 its deviceId to room.changeMic() or as microphoneId to createMicrophoneAudioTrack().

  • MicrophoneDeviceInfo has three properties:

    1. MicrophoneDeviceInfo.deviceId

      • Returns SPEAKER_PHONE, EARPIECE, WIRED_HEADSET or BLUETOOTH.
    2. MicrophoneDeviceInfo.label

      • Returns a string describing this device (for example BLUETOOTH).
    3. MicrophoneDeviceInfo.kind

      • Returns Kind.audio.

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 Permission stands for these Android permissions, which your app must also declare in its AndroidManifest.xml:

    • Permission.audio: RECORD_AUDIO and MODIFY_AUDIO_SETTINGS.
    • Permission.video: CAMERA.
    • Permission.bluetooth: BLUETOOTH_CONNECT on Android 12 and later. On older versions it asks for nothing.

Parameters​

  • context

    • type: Context
    • REQUIRED
    • Pass an Activity. Another context works only when options.createNewTask is true.
  • permission

    • type: List<Permission>
    • REQUIRED
    • The permission groups to request.
  • 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.
  • 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, sendBlockedToSettings and createNewTask.
  • permissionHandler

    • type: PermissionHandler
    • REQUIRED
    • Tells you the outcome: onGranted(), onDenied(), onBlocked() (the user chose "don't ask again" earlier) or onJustBlocked() (the user chose it during this request).
    • Return true from onBlocked() 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.

Which dialogs the user sees​

  • The first request goes straight to the system prompt. The rationale dialog 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 when onBlocked() returns false (the default) and options.sendBlockedToSettings is true (the default).
  • When the user comes back from Settings, the SDK checks again. A permission that is still blocked shows the dialog again.
note

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 its deviceId as cameraId to createCameraVideoTrack().

Parameters​

  • selectedVideoDevice: CameraDeviceInfo
    • Pass a camera from getCameras().

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() or room.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_COMMUNICATION when join() completes and back to AudioManager.MODE_NORMAL when you leave, so most apps never call it.

  • Call it after join() returns, for example with MODE_NORMAL for 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() as customCameraTrack, or publish it with room.enableCam(track).

  • It is a suspend function: it returns once the camera is open, and throws if the camera can't be opened. You can call it from the main thread. Call stop() 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 encoderConfig values.

createCameraVideoTrack
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​

  • IllegalStateException if VideoSDK.initialize() has not run.
  • VideoSDKException: 3017 if the CAMERA permission isn't granted, 3021 if the device has no camera, 3071 if cameraId matches no camera, 3053 if the capture profile cannot be read, 3023 if another app is using the camera, 3019 if a device policy has disabled the camera, and 3026 if 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: set onEnded on 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() as customMicrophoneTrack, or publish it with room.unmuteMic(track). Nothing is sent until the track is published. Call stop() on the track to close the microphone.

  • It is a suspend function: 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.

createMicrophoneAudioTrack
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_QUALITY or HIGH_QUALITY_STEREO.
    • Default: CustomMicrophoneTrackConfig.SPEECH_STANDARD
  • microphoneId

    • type: String?
    • OPTIONAL
    • The deviceId of a device from getMics(). If it is not provided, the current device is used.
  • 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: true for the first three and false for highPassFilter. If you don't pass one, the encoderConfig decides.

Throws​

  • IllegalStateException if VideoSDK.initialize() has not run.
  • VideoSDKException: 3018 if the RECORD_AUDIO permission isn't granted, 3022 if the device has no microphone, 3071 if microphoneId matches no device, and 3024 if 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 Intent that MediaProjectionManager returns and returns it. Publish the track with room.enableScreenShare(track). Screen capture starts only then.

  • It returns null when the user declined the consent dialog (data is null), or when encoderConfig is not a known profile. The second case also reports 3071 (ERROR_INVALID_CUSTOM_TRACK_CONFIG) on onError while you are in a room.

  • withAudio = true also captures the audio playing on the device and mixes it into your microphone track, so muting the microphone mutes both. No separate SHARE_AUDIO stream is sent, so other participants hear it in your microphone stream and getShareAudioStats() returns null for you. It needs Android 10 (API 29) or later and the RECORD_AUDIO permission.

  • Refer to Custom Tracks for the supported encoderConfig values.

createScreenShareVideoTrack
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 suspend function: it returns the PreCallTestResult when the test finishes, or throws PreCallTestException when the test fails. Cancelling the coroutine stops the test, and so does stopPreCallTest().

  • onStatsChange runs on the main thread each time the test samples the network.

  • VideoSDK.initialize() must have run first, or it throws IllegalStateException. The test doesn't ask for the CAMERA or RECORD_AUDIO permissions: request them first with checkPermissions().

  • Without a videoTrack or audioTrack in the options, the test opens the devices itself. After a test that succeeds, those tracks stay open and are yours: they are result.camera?.track and result.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.

runPreCallTest
suspend fun runPreCallTest(
options: PreCallTestOptions,
onStatsChange: ((PreCallNetworkQuality) -> Unit)? = null,
): PreCallTestResult

Parameters​

  • options

    • type: PreCallTestOptions
    • REQUIRED
    • The test settings: token is required, and samplingDuration, audioOnly, videoTrack, audioTrack, videoConfig and audioConfig are optional.
  • onStatsChange

    • type: ((PreCallNetworkQuality) -> Unit)?
    • OPTIONAL
    • Receives each network sample while the test runs.

Returns​

  • PreCallTestResult

Throws​

  • PreCallTestException when the test fails. Its code names the reason, for example ERROR_PRECALL_INVALID_CONFIG or ERROR_PRECALL_TEST_ALREADY_RUNNING.
  • IllegalStateException if VideoSDK.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 whose aborted is true, with whatever was measured until then, or throws PreCallTestException if 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, onError reports 3080 (ERROR_VIDEO_EFFECTS_GRAPH_UNAVAILABLE) once, and the camera stays on Pipeline.LEGACY: the call keeps going, but the video is sent without effects. A GRAPH request made before any camera has started is not an error. Read applied and reason in the returned value, or call getAppliedVideoEffectsConfig(), to find out what is running.

  • Before any camera has started, a GRAPH request returns applied false with a reason that starts with pending:. It is kept, and the next camera start runs it.

Parameters​

  • config

    • type: VideoEffectsConfig
    • REQUIRED
    • pipeline: Pipeline.LEGACY (the default, no effects) or Pipeline.GRAPH.
    • framing: Framing(enabled, maxZoom). Crops and zooms to keep the subject you publish with publishFramingSubject() in the centre.
    • lighting: Lighting(enabled, strength). Brightens dark parts of the picture.
    • style: Style(preset, strength, levels), with the preset StylePreset.OFF, POSTERIZE or VIVID.
    • filter: Filter(lut, strength), with the grade Lut.OFF, WARM, COOL or MONO.
    • Every effect is off unless you turn it on.

Returns​

  • JSONObject - The configuration the SDK applied, with applied (false when the request can't be honoured) and reason.

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 GRAPH request the device can't run reports applied as false with a reason, 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.0 to 1.0. Auto-framing must be on: VideoEffectsConfig.Framing(enabled = true) with Pipeline.GRAPH, set with setVideoEffects().

  • 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 width or height of 0 or 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 with CaptureFlash.ON on a front camera that has no flash.

  • Pass ScreenFlash.whiteOverlay(activity) for a white screen at full brightness, your own ScreenFlash implementation for a custom UI, or null to capture without light. The show() and hide() methods of a ScreenFlash are called on the main thread, and hide() 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 with setParticipantKey() 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 before room.join().

Returns​

  • Unit

Example​

VideoSDK.removeKeyProvider()

getKeyProvider()​

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 throws VideoSDKException with 3073 (ERROR_INVALID_PARAMETER).

  • Pass null as 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 of VideoSDK. It removes one participant's key.
  • On the provider you passed to setKeyProvider(), it does the same as setParticipantKey(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 onStreamDisabled and onStreamEnabled for 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 false to 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.INFO until 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

Returns​

  • Unit

Example​

VideoSDK.setLogLevel(LogLevel.DEBUG)

getLogLevel()​

  • It returns the level set with setLogLevel(), or LogLevel.INFO if 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 what isTelemetryEnabled() returns.

Returns​

  • Unit

isTelemetryEnabled()​

  • It returns whether telemetry is on: true until you call disableTelemetry().

Returns​

  • Boolean

getErrorCodes()​

  • It returns a JSONObject that maps every error name to its code, for example INVALID_TOKEN to 4002.

  • Use it to look up a code by name. You can also pass a code to VideoSDKError.fromCode(code) to get the matching VideoSDKError.

  • 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