CXR-L(EN)
CXR-L(EN)
IntroductionQuick StartDevelopment Flow & State-MachineTerms and Abbreviations
Feature Development
Version HistoryAndroid
iOS
cxr-l-sdk · v1.0.1 · snapshot 2026-05-13· ↗ source
Custom Commands
Android: Custom Command
Scenario
On an established CUSTOMAPP session and the same CXRLink instance, use Caps to serialize the payload, send a custom command to the glasses via sendCustomCmd, and receive responses in ICustomCmdCbk. In CXRLSample, the send button is enabled only when entering from the CustomApp flow and entryType is customApp.
Prerequisites
- In
CustomCmdViewModel.init,_available = (entryType == ENTRY_TYPE_CUSTOM_APP). CXRLSampleApplication.sharedCxrLinkis not null (i.e., you have gone throughCustomAppTypeViewModel.initand calledconnect).- The glasses-side Custom App scene has been built: the target app has been opened on the glasses via
openApp, etc. (in the Sample, the entry toCustomCmdActivityis provided only afterappOpened == trueinCustomAppTypeScreen; do not send commands immediately afterconnectsucceeds while the app is not launched yet).
Under CUSTOMVIEW, the Sample sets _available to false and does not demonstrate sending (aligned with product constraints: custom commands should be used within a glasses-side app session).
Key APIs
| Method | Description |
|---|---|
setCXRCustomCmdCbk(ICustomCmdCbk) | Register callback. |
sendCustomCmd(key: String, payload: ByteArray) | Send. The Sample uses Caps().serialize() as payload. |
Callback
onCustomCmdResult(key: String?, payload: ByteArray?):
- The Sample handles responses only when
key == “rk_custom_key”. - It deserializes via
Caps.fromBytes(payload)and recursively renders withparseCapsinto the UI.
Send example (same as the Sample)
cxrLink.sendCustomCmd(“rk_custom_client”, Caps().apply {
write(“rk_custom_key”)
write(“from client click times = ${count++}”)
}.serialize())
The glasses side must agree on channels/keys such as rk_custom_client / rk_custom_key and their semantics.
Constraints
- Send only when
onCXRLConnected(true)and Bluetooth is in an available state. The Sample gates this via_ready. - Protocol version, endianness, and maximum packet size must match the glasses side, otherwise you may see silent failure or truncation.
- On page
release, set_readyto false to avoid background sends.
Sample reference paths
activities/customCMD/CustomCmdViewModel.ktactivities/customCMD/CustomCmdActivity.kt