Implementation

Once installation is complete and you have a valid token, launching the full video UI takes only a few lines of Kotlin code. The core integration is a single component — EnxVideoView — which you initialize with your token and add to your Activity's layout. Everything else — rendering, controls, event handling, chat, screen share — is managed internally.

Prerequisites

Before writing integration code, confirm the following are in place:

Runtime Permissions

Camera and microphone permissions are "dangerous" permissions in Android and must be requested at runtime (not just declared in the manifest). Request them before initializing EnxVideoView. If either permission is denied, the session will fail to start.

Step 1 — Import Packages

Add the following imports to your Activity file. EnxVideoView is the main UI component, and EnxVideoStateObserver is the interface your Activity implements to receive lifecycle callbacks.

import com.enablex.enxuikit_android.observer.EnxVideoStateObserver
import com.enablex.enxuikit_android.view.EnxVideoView
Step 2 — Initialize EnxVideoView

EnxVideoView is a subclass of RelativeLayout. You instantiate it by passing four arguments: your Activity context, the room token, an observer for callbacks, and an optional Low Code embed URL. Once created, you set layout parameters and add it to the Activity's content view.

The optional embedUrl parameter links the session to a configuration defined in the EnableX Low Code Visual Builder in the Portal. If you are not using Visual Builder, pass an empty string or omit it.

// Initialize EnxVideoView
enxVideoView = EnxVideoView(
    this,                    // Activity context
    token,                   // Valid room token from your server
    this,                    // Observer for lifecycle callbacks
    "Low Code Embed URL"     // Optional: imports Low Code settings
)

// Set layout parameters to fill the screen
val rlp = RelativeLayout.LayoutParams(
    RelativeLayout.LayoutParams.MATCH_PARENT,
    RelativeLayout.LayoutParams.MATCH_PARENT
)

// Add the video view to your Activity's layout
this.addContentView(enxVideoView, rlp)
EnxVideoView Manages Everything

EnxVideoView handles all video rendering, toolbar controls, participant tiles, chat, screen share, and event handling internally. You do not need to manage media streams, WebRTC tracks, or individual UI elements directly.

Step 3 — Handle Callbacks

Your Activity must implement the EnxVideoStateObserver interface. This interface defines two required callbacks that notify you of session end and connection failure events. Use these callbacks to clean up your UI, navigate the user away, or display an error message.

disconnect

Called when the user successfully disconnects from the video room — either by pressing the end-call button in the UI or programmatically. The jsonObject parameter contains details about why the session ended.

// Called when the user disconnects from the video room
override fun disconnect(jsonObject: JSONObject?) {
    // jsonObject contains the reason for disconnection
    // Clean up your UI, navigate away, release resources, etc.
}

connectError

Called when the connection to the video room fails. This can happen if the token is invalid or expired, if the room does not exist, or if there is a network error during the initial connection handshake. The jsonObject parameter contains the error details.

// Called when connection to the video room fails
override fun connectError(jsonObject: JSONObject?) {
    // jsonObject contains the error details
    // Show an error message to the user, log for diagnostics, etc.
}
Always Handle Both Callbacks

Both disconnect and connectError must be implemented. Failing to handle connectError can leave the user stranded on a blank screen if the connection attempt fails.