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
Glasses Custom View
Android: Glasses-side Custom View
Scenario
In a CUSTOMVIEW session, deliver layout JSON and icon resources (Base64) from the phone to render UI on the glasses, and support open / update / close. CXRLSample demonstrates a composition of LinearLayout, TextView, and ImageView, plus two rounds of icon switching.
Prerequisites
- You have completed “Connection and Session”. The current
CXRLinkisCUSTOMVIEWandconnect(token)has been called. ICustomViewCbkis registered (see the SampleCustomViewTypeViewModel).
Key APIs
| Method | Description |
|---|---|
customViewSetIcons(String) | Pass the icon-list JSON string. In the Sample it is called when onCXRLConnected(true) and iconsString is not empty. |
customViewOpen(String) | Pass the full view-tree JSON (first open). |
customViewUpdate(String) | Pass the update JSON (serialized from UpdateViewJson). |
customViewClose() | Close the current Custom View. |
The icon JSON format is generated by toJson(list: List<IconInfo>) in the Sample. Each element contains name and data (Base64).
Callbacks (ICustomViewCbk)
| Callback | Sample behavior |
|---|---|
onCustomViewOpened | Marks the Custom View as opened. |
onCustomViewUpdated | Logs. |
onCustomViewClosed | Clears the “opened” mark. |
onCustomViewIconsSent | Logs “icons sent successfully”. |
onCustomViewError(code, msg?) | Clears the “opened” mark on errors. |
Recommended call order
connect_okcustomViewSetIconscustomViewOpencustomViewUpdate_optionalcustomViewClose
- After the connection succeeds and the icon string is ready, call
customViewSetIcons(it can also be triggered automatically in the connection callback). - Call
customViewOpento deliver the root layout and child nodeprops. - For partial refresh, build
UpdateViewJson(contains only changed nodeidandprops) and callcustomViewUpdate. - When leaving, call
customViewClose.
Constraints
- In the layout JSON, the
nameof anImageViewmust matchIconInfo.namein the icon list, otherwise the resource cannot be resolved. - JSON field names and units (
dp/sp) must match the protocol. Before changing the structure, read Sample models such asSelfViewJson,TextViewProps,ImageViewProps. - Custom View is different from app control under a CustomApp session—do not mix session types.
- Scene building: only after
customViewOpensucceeds and you receiveonCustomViewOpened(customViewOpened == truein the Sample) should you enter sub-capabilities such as Audio and Photo (in the Sample,CustomViewTypeScreenshows “Enter Audio / Enter Photo” only after the view is opened).
Sample reference paths
activities/customViewType/CustomViewTypeViewModel.ktactivities/customViewType/CustomViewTypeActivity.ktdataBean/selfView/*