audio-streaming
Receive synchronized PCM audio frames through a Camera stream on Android
Session state, stream state, pause and resume behavior, and device availability monitoring
$ npx -y skills add facebook/meta-wearables-dat-android --skill session-lifecycle --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/session-lifecycleContext preview
The summary Claude sees to decide when to auto-load this skill.
Session state, stream state, pause and resume behavior, and device availability monitoring
name: session-lifecycle description: Session state, stream state, pause and resume behavior, and device availability monitoring
Manage session and stream state in DAT SDK integrations.
Create a `DeviceSession` with `Wearables.createSession(...)`, start it, then attach capabilities such as camera streaming once the session is `STARTED`. Session lifecycle and capability lifecycle are related but distinct.
| State | Meaning | App action | |-------|---------|------------| | `IDLE` | Session created, not started yet | Call `session.start()` | | `STARTING` | Connecting to the device | Show loading UI | | `STARTED` | Session active and ready for capabilities | Add or use capabilities | | `PAUSED` | Session temporarily suspended | Keep state, wait for resume or stop | | `STOPPING` | Session is shutting down | Stop user work and wait | | `STOPPED` | Terminal; session ended | Release resources and create a new session if needed |
`STOPPED` is terminal: a stopped session cannot be restarted, so call `Wearables.createSession(...)` again for the next connection.
`start()` and `stop()` are both sync fire-and-forget and return `Unit`. Subscribe to `state` and `errors` before calling `start()` so no transition is missed, and treat `session.errors` as the failure channel for `start()`.
Wearables.createSession(AutoDeviceSelector()).fold(
onSuccess = { session ->
lifecycleScope.launch {
session.state.collect { state ->
when (state) {
DeviceSessionState.STARTED -> onStarted(session)
DeviceSessionState.PAUSED -> onPaused()
DeviceSessionState.STOPPED -> onStopped()
else -> Unit
}
}
}
lifecycleScope.launch {
session.errors.collect { error -> showError(error.description) }
}
session.start()
},
onFailure = { error, _ -> showError(error.description) },
)Add capabilities from `onStarted(session)`. Calling `session.addCamera(...)` while the session is still `IDLE` fails with `DeviceSessionError.SESSION_IDLE`, and calling it after `STOPPED` fails with `DeviceSessionError.SESSION_ALREADY_STOPPED`.
Camera streaming has its own state flow after you add a camera:
STOPPED -> STARTING -> STARTED -> STREAMING -> STOPPING -> STOPPED
`CLOSED` is the terminal stream state, and `PAUSED` is reported when the device pauses streaming (for example a single cap-touch tap) and can resume on its own.
lifecycleScope.launch {
camera.stream.state.collect { state ->
// React to stream state changes
}
}The SDK may pause or stop a session when:
When a session is paused:
lifecycleScope.launch {
Wearables.devices.collect { devices ->
// Update the list of available devices
}
}Use `Wearables.devices` and device metadata to decide when it is sensible to create a new session after a stop.
The Meta Wearables Device Access Toolkit enables developers to utilize Meta's AI glasses to build hands-free wearable experiences into their mobile applications.
Receive synchronized PCM audio frames through a Camera stream on Android
Capture standalone high-quality photos from connected glasses on Android
Session and Stream capability setup, video frames, photo capture, resolution and frame rate configuration
Kotlin patterns, DatResult, session and capability conventions for DAT SDK Android development
Use the Wearables DAT MCP server for live DAT documentation search with `search_dat_docs`, Muse Code, Claude Code, Codex, Cursor,…