dat-conventions

bởi facebook

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

npx skills add https://github.com/facebook/meta-wearables-dat-android --skill dat-conventions

DAT SDK Conventions (Android)

Quick Reference

TaskCommand
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: Stream 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

Wearables.initialize(context)

val session = Wearables.createSession(AutoDeviceSelector()).getOrElse { error ->
    throw IllegalStateException(error.description)
}
session.start()

val camera = session.addCamera(StreamConfiguration()).getOrElse { error ->
    throw IllegalStateException(error.description)
}
camera.stream.start().getOrElse { error ->
    throw IllegalStateException(error.description)
}

Kotlin patterns

  • Use DatResult<T, E> for typed success and failure handling
  • Observe state with StateFlow and Flow
  • Create a Session first, then attach capabilities such as Stream or Display
  • Keep frame handling off the main thread when doing heavier processing

Error handling

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

TypePurposeExample
SessionDevice connection lifecycleWearables.createSession(...)
StreamCamera capability on a sessionsession.addCamera(...)camera.stream
DisplayDisplay capability on a sessionsession.addDisplay(...)
*SelectorDevice targetingAutoDeviceSelector
*ErrorTyped failure surfaceSessionError, StreamError

Key types

  • Wearables — SDK entry point
  • Session — lifecycle for an interaction with a linked device
  • Stream — camera capability attached to a session
  • Display — display capability attached to a session
  • StreamConfiguration — video quality and frame rate 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.

Use llms.txt when your tool only supports static reference context.

Testing with MockDeviceKit

val mockDeviceKit = MockDeviceKit.getInstance(context)
mockDeviceKit.enable()
val device = mockDeviceKit.pairGlasses(GlassesModel.RAYBAN_META).getOrThrow()

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 assume a session implies streaming or display access; capabilities are attached separately
  • Do not ignore DatResult failures from createSession, start, addCamera, addDisplay, or capturePhoto
  • Do not reuse terminally stopped sessions

Links

Thêm skills từ facebook

api-health
facebook
Theo dõi tình trạng API cho ứng dụng Meta — kiểm tra giới hạn tỷ lệ, khối lượng cuộc gọi và các API bị ngừng hỗ trợ. Dùng để chẩn đoán tình trạng hạn chế, lập kế hoạch dung lượng hoặc chuẩn bị cho phiên bản API…
official
api-integration
facebook
Hướng dẫn nhà phát triển thiết lập tích hợp Meta API từ đầu — khám phá các API phù hợp, tìm nạp hướng dẫn thiết lập, yêu cầu xác thực,…
official
app-review-prep
facebook
Prepare a Meta app for App Review — checks current status, outstanding requirements, granted privileges, and submission history. Use before submitting an app…
official
debug-webhooks
facebook
Troubleshoot webhook issues for a Meta app — inspect active subscriptions, identify misconfiguration, and send test payloads to verify delivery. Use when…
official
webhook-setup
facebook
Set up webhooks for a Meta app end-to-end — discover available topics, subscribe to fields, and verify with a test payload. Use when configuring webhooks for…
official
buck2-rule-basics
facebook
Guide users through writing their first Buck2 rule to learn fundamental concepts including rules, actions, targets, configurations, analysis, and select(). Use…
official
add-ir-instruction
facebook
Hướng dẫn thêm một chỉ thị IR mới vào trình biên dịch Hermes. Sử dụng khi người dùng yêu cầu thêm, tạo hoặc định nghĩa một chỉ thị IR mới (Inst/Instruction) trong…
official
binary-size-analysis
facebook
This skill should be used when the user wants to analyze hermesvm binary size changes across a range of commits. Use when the user mentions "binary size",…
official