Skip to content
Mobile
Skill

/dat-conventions

Kotlin patterns, DatResult, session and capability conventions for DAT SDK Android development

From plugin
meta-wearables-dat-android
40718 skills

Claude Code

$ npx -y skills add meta/meta-wearables-dat-android --skill dat-conventions --agent claude-code

SKILL.md

dat-conventions.SKILL.md
name: dat-conventions
description: Kotlin patterns, DatResult, session and capability conventions for DAT SDK Android development

DAT SDK Conventions (Android)

Quick Reference

| Task | Command | |------|---------| | Build app | `./gradlew assembleDebug` | | Run tests | `./gradlew test` | | Install app | `./gradlew installDebug` | | Lint app | `./gradlew lint` |

Architecture

The SDK is organized into four public modules:

  • **mwdat-core**: Registration, permissions, devices, and session creation
  • **mwdat-camera**: Camera capability, video frames, and photo capture
  • **mwdat-display**: Display capability, display UI components, icons, images, buttons, and video
  • **mwdat-mockdevice**: MockDeviceKit for testing without hardware

Initialization and session setup

`DeviceSession.start()` is fire-and-forget and returns `Unit`; capabilities can only be attached once the session reports `DeviceSessionState.STARTED`.

Wearables.initialize(context)

var camera: Camera? = null

Wearables.createSession(AutoDeviceSelector()).fold(
    onSuccess = { session ->
        lifecycleScope.launch {
            session.state.collect { state ->
                if (state == DeviceSessionState.STARTED && camera == null) {
                    session.addCamera(StreamConfiguration()).fold(
                        onSuccess = { addedCamera ->
                            camera = addedCamera
                            addedCamera.stream.start().onFailure { error, _ ->
                                showError(error.description)
                            }
                        },
                        onFailure = { error, _ -> showError(error.description) },
                    )
                }
            }
        }
        lifecycleScope.launch {
            session.errors.collect { error -> showError(error.description) }
        }
        session.start()
    },
    onFailure = { error, _ -> showError(error.description) },
)

Kotlin patterns

  • Use `DatResult<T, E>` for typed success and failure handling
  • Prefer `fold`, `onSuccess`, and the two-parameter `onFailure { error, cause -> }` overload, which hands you the typed `DatError` with a `description`
  • `getOrElse { }` receives a raw `Throwable`, not a typed `DatError`, so it cannot read `error.description`
  • Observe state with `StateFlow` and `Flow`
  • Create a `DeviceSession` first, then attach capabilities such as `Camera` or `Display` after it reaches `STARTED`
  • Keep frame handling off the main thread when doing heavier processing

Error handling

lifecycleScope.launch {
    Wearables.checkPermissionStatus(Permission.CAMERA)
        .onSuccess { status -> /* handle status */ }
        .onFailure { error, _ -> /* handle error */ }
}

Avoid `getOrThrow()` in user-facing samples. Surface typed errors from `DatResult` instead.

Naming conventions

| Type | Purpose | Example | |------|---------|---------| | `DeviceSession` | Device connection lifecycle | `Wearables.createSession(...)` | | `Camera` | Camera capability on a session | `session.addCamera(...)` | | `Stream` | Video stream from a camera | `camera.stream` | | `Display` | Display capability on a session | `session.addDisplay(...)` | | `*Selector` | Device targeting | `AutoDeviceSelector`, `SpecificDeviceSelector` | | `*Error` | Typed failure surface | `DeviceSessionError`, `StreamError`, `CaptureError` |

Key types

  • `Wearables` — SDK entry point
  • `DeviceSession` — lifecycle for an interaction with a linked device
  • `Camera` — camera capability attached to a session
  • `Stream` — video stream accessed through `camera.stream`
  • `Display` — display capability attached to a session
  • `StreamConfiguration` — video quality, frame rate, and compression configuration
  • `MockDeviceKit` — simulated device environment for testing

Live docs search

If your editor supports remote MCP servers, connect `https://mcp.developer.meta.com/wearables` and use `search_dat_docs` for current DAT setup, session lifecycle, camera streaming, MockDeviceKit, permissions, and exact API symbols. This public docs server does not require authentication; do not configure tokens, OAuth, or custom authorization headers for it.

See the `dat-docs-mcp` skill for client setup and troubleshooting. Use `llms.txt` when your tool only supports static reference context.

Testing with MockDeviceKit

val mockDeviceKit = MockDeviceKit.getInstance(context)
mockDeviceKit.enable()
mockDeviceKit.pairGlasses(GlassesModel.RAYBAN_META).fold(
    onSuccess = { device -> onMockDevicePaired(device) },
    onFailure = { error, _ -> showError(error.description) },
)

Use MockDeviceKit to drive registration, device availability, streaming media, and permission scenarios without physical hardware.

Common pitfalls

  • Do not call SDK APIs before `Wearables.initialize(context)`
  • Do not call `addCamera(...)` or `addDisplay()` immediately after `session.start()`; wait for `DeviceSessionState.STARTED`
  • Do not assume a session implies streaming or display access; capabilities are attached separately
  • Do not ignore `DatResult` failures from `createSession`, `addCamera`, `addDisplay`, `stream.start()`, or `capturePhoto`; `session.start()` returns `Unit`, so watch `session.errors` for its failures
  • Do not reuse terminally stopped sessions, cameras, or streams

Links

  • [Android API reference](https://wearables.developer.meta.com/docs/reference/android/dat/latest)
  • [Developer documentation](https://wearables.developer.meta.com/docs/develop/)
  • [GitHub repository](https://github.com/meta/meta-wearables-dat-android)
Read more
@facebook
Ships withmeta-wearables-dat-android

The Meta Wearables Device Access Toolkit enables developers to utilize Meta's AI glasses to build hands-free wearable experiences into their mobile applications.

Stars on GitHub

Momentum

stars in total
407
Star history of facebook/meta-wearables-dat-android on GitHub, a chart by star-history.com

More skills from other plugins.

deep-code-review

deep-code-review

In-depth design-focused code review - understands codebase context before evaluating PR changes, posts structured feedback to…

expo11d53k
@expo@expoInstall Skill
modlens

modlens

Plug-in vision for text-only models. Hard rule: when a file path or URL with an image extension (.png, .jpg, .jpeg, .webp, .gif,…

modlens4w4.6k
@liustack@liustackInstall Skill
appllama-app-design-skill

appllama-app-design-sk…

Build native-feeling, benchmark-quality mobile app screens (Expo / React Native). Use when designing or implementing any mobile…

appllama2mo3.9k
@appllama@appllamaInstall Skill

Questions about dat-conventions.

Which coding agents can use dat-conventions?
dat-conventions installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.