CXR-L(EN)
cxr-l-sdk · v1.0.1 · snapshot 2026-05-13· ↗ source

Photo Capture

Android: Photo Capture

Scenario

On an existing CXRLink, register an image stream callback and call takePhoto(width, height, quality) to trigger photo capture on the glasses. Receive JPEG-compressed bytes via IImageStreamCbk.onImageReceived, then decode and display the bitmap on the phone.

Prerequisites

  • Same as “Audio”: relies on CXRLSampleApplication.sharedCxrLink, which is initialized and connected by the CustomView or CustomApp page.
  • The glasses-side scene is built: call takePhoto only after the Custom View is opened or the Custom App has been launched via openApp (the Sample navigates here from the corresponding scene page; gating is aligned with Audio).

Key APIs

MethodDescription
setCXRImageCbk(IImageStreamCbk)Register photo result callback.
takePhoto(width: Int, height: Int, quality: Int)The Sample uses 1024, 768, 80.

Callbacks (IImageStreamCbk)

CallbackSample behavior
onImageReceived(data: ByteArray?)_photoTaking=false, decodes to ImageBitmap and shows it.
onImageError(code, msg?)Shows failure prompt and clears the image.

Constraints

  • Higher resolution/quality increases transport latency and memory usage. Balance clarity vs performance for your product.
  • For continuous captures, start the next capture only after the previous one completes (callback received) to avoid protocol-layer concurrency issues.
  • If the link disconnects and onGlassBtConnected(false) causes _ready=false in the Sample, do not call takePhoto.

Sample reference paths

  • activities/photo/PhotoUsageViewModel.kt
  • activities/photo/PhotoUsageActivity.kt
Marcin Miazga