Index of every page on this site: llms.txt
All skills
android avatar

/camerax

@7f7b217
by androidandroid/skills11k stars
703
Run it yourself

Provide technical guidance for Android camera development with CameraX. Use when implementing camera features, handling asynchronous recording lifecycles, wiring low-level hardware interop using CameraX, or integrating ML Kit or Media3 effects.

Use this Skill: https://skilld.dev/gh/android/skills/camerax

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referenceswear-os.md

≈792 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Developing camera features for Wear OS is rarely about the watch's own lens, if it even has one. It's almost always about creating a Remote Viewfinder to control the phone's camera.

The Wear OS remote mindset

Feature Phone camera app Wear OS remote app
Screen Rectangular (Large) Circular and less than 2 inches in size
Connectivity Local Hardware Bluetooth or Wi-Fi data layer API
Latency Direct and less than 20 ms Networked, 100 ms to 500 ms
Interaction Multi-touch gestures Rotary input or single taps

Follow the implementation guide

The circular UI challenge

Wear OS devices are often round. Standard rectangular layouts clip corner buttons.

Follow these blueprint recommendations:

  • Use Horologist or Wear Compose libraries.
  • Use ScalingLazyColumn for lists so that items stay within the "safe zone" of the circular display.
  • Preview scaling: Crop the center of the rectangular phone viewfinder to fit the circular watch screen.

Stream the viewfinder

You can't send a raw 60 fps stream over Bluetooth. compress and throttle.

/** Phone side: sends a compressed viewfinder frame to the watch. */
suspend fun sendPreviewFrame(context: Context, previewView: PreviewView) {
    val bitmap = previewView.bitmap ?: return // Capture current frame on the main thread
    val compressed = withContext(Dispatchers.Default) { // Compress off the main thread
        ByteArrayOutputStream().use { stream ->
            bitmap.compress(Bitmap.CompressFormat.JPEG, 50, stream)
            stream.toByteArray()
        }
    }
    val request = PutDataMapRequest.create("/camera/preview").apply {
        dataMap.putAsset("image", Asset.createFromBytes(compressed))
    }
    Wearable.getDataClient(context).putDataItem(request.asPutDataRequest())
}
<br />

Optimization : Cap the watch preview at 10-15 fps to preserve battery and bandwidth.

Remote triggers and syncing

Use the MessageClient for low-latency commands like "Take Photo" or "Switch Camera."

/** Watch side: sends a capture trigger to the phone node. */
fun sendCaptureTrigger(context: Context, phoneNodeId: String) {
    Wearable.getMessageClient(context).sendMessage(phoneNodeId, "/camera/capture", null)
}
<br />

Rotary input support

On devices that support it, use the physical crown, Rotary Input, to control Zoom or Exposure.


Wear OS pitfalls

  • Corner clipping : Placing a Close button in the top-right corner of a square layout makes it impossible to tap the button on a round watch display.
  • Battery drain: Sustained Bluetooth data transfer, viewfinder sync, drains watch battery. Proactively close the remote app if the phone screen is turned off.
  • Node discovery : The phone is possibly connected to multiple "Nodes" (watches, earbuds, or tablets). Ensure your CapabilityClient filters for the specific camera_remote_host capability.
  • Disconnect handling: If the watch disconnects, the phone camera must stop its high-power preview to save energy.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts6d3 checks · Risk SAFE
  • Gen Agent Trust Hub7d

    The skill provides technical guidance for Android CameraX development, covering migration from legacy APIs, handling device diversity (foldables, Wear OS, XR), and integrating with ML Kit and Media3. No security issues were detected; all code snippets and external references originate from trusted sources and follow standard platform patterns.

  • Socket6d

    No alerts

  • Snyk7d

    Risk: LOW · No issues

Signed by skilld at 7f7b217. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 1 hour ago.

Activeupdated last week
Other metadata
metadata
{
  "author": "Google LLC",
  "last-updated": "2026-11-10",
  "keywords": [
    "recipe",
    "Android",
    "Camera",
    "Camera1",
    "Camera2",
    "CameraX",
    "migration",
    "Compose",
    "guide",
    "dependencies",
    "PreviewView",
    "CameraXViewfinder",
    "ImageCapture",
    "VideoCapture",
    "ImageAnalysis."
  ]
}

README badge

README badge for android/skills/camerax