Introduction
CXR-L SDK Introduction
Positioning
The CXR-L SDK runs on the mobile phone. It works together with Rokid Glasses and the Rokid AI App to complete authentication, session establishment, and capabilities such as Custom View, glasses-side app control, audio, photo capture, and custom commands.
Typical flow:
- The mobile app integrates the SDK and guides the user to install/launch Rokid AI App.
- Obtain a
tokenthrough the companion authorization flow. - Establish a
CustomVieworCustomAppsession and keep the link available (connectsucceeds and service-side conditions such as Bluetooth are satisfied). - Complete scene building: the glasses side has actually presented the UI or app process required by the target capability (see “Scene building” below).
- After the scene is ready, use capabilities such as photo capture, audio, and custom commands. APIs for connection/Custom View/app control should still be called in the order described in each chapter.
Scene building (important) means the glasses side has reached the business-agreed working state, rather than only the phone-side connect returning success.
- Custom View scenario: in a
CUSTOMVIEWsession,customViewOpen(or an equivalent operation) succeeds and the “view opened” callback is received; the glasses show the Custom View UI. - Custom App scenario: in a
CUSTOMAPPsession, the target package is installed andopenAppsucceeds; the glasses-side app is in the foreground/interactive (the Sample usesappOpenedto indicate the scene is opened).
Photo capture, audio, and custom commands must be called only after scene building is completed for the corresponding scenario. Merely establishing a session or merely having the link connected is not sufficient to guarantee these capabilities are effective. Among them, custom commands must be used in the Custom App scenario.
Core capabilities
| Capability | Description |
|---|---|
| Connection and session | Create the link instance, connect to Rokid AI/Hi Rokid APP, configure the session type, and register state callbacks. |
| Glasses-side Custom View | Deliver layout JSON and icon resources; supports open, update, and close. |
| Glasses-side Custom App | Query installation status, upload & install APK, start, stop, and uninstall the target package. |
| Custom command | Bidirectional custom messages (used together with the CUSTOMAPP session). |
| Audio | Start/stop audio stream and receive PCM data. |
| Photo capture | Trigger photo capture with specified resolution and quality, and receive JPEG bytes. |
Capability prerequisites
| Capability | Prerequisites |
|---|---|
| Audio | After scene building is completed: in the CustomView flow, customViewOpen must have succeeded; in the CustomApp flow, openApp must have succeeded (the glasses-side scene is opened). Reuse the global CXRLink. |
| Photo capture | Same as audio. |
| Custom command | CustomApp only; and only after the glasses-side app is opened. |
Capability availability matrix (summary)
| Session / state | Audio | Photo | Custom command |
|---|---|---|---|
| Not authenticated / no token | No | No | No |
Authenticated but not connected | No | No | No |
connected but scene building not completed (custom view not opened / app not opened) | No | No | No |
CUSTOMVIEW and the Custom View is opened | Yes | Yes | No |
CUSTOMAPP and the glasses-side app is opened | Yes | Yes | Yes (must reuse the same CXRLink) |
Reading map
| Purpose | Doc |
|---|---|
| Environment and minimal end-to-end run | Quick Start |
| Flow and state | Development Flow and State Machines |
| Step-by-step Android integration | Feature Development/Android |
| Step-by-step iOS integration | Feature Development/iOS |
| Terminology alignment | Terms and Abbreviations |
Sample projects
- Android: CXRLSample (
com.rokid.cxrlsample), depends oncom.rokid.cxr:client-l(use the projectapp/build.gradle.ktsas the source of truth for the version). - iOS: ios_cxr_l_sample (clone the full repo before cross-checking class names and paths in the docs).
In the Android Sample, the glasses-side companion demo app package name is com.rokid.cxrswithcxrl in the CONSTANT.APP_PACKAGE_NAME constant, used for CUSTOMAPP install and launch demos.