一键导入
session-lifecycle
Session state, stream state, pause and resume behavior, and device availability monitoring
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Session state, stream state, pause and resume behavior, and device availability monitoring
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
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
Common issues, Developer Mode, version compatibility, and session and stream diagnosis
Display capability setup, display-capable device selection, UI DSL, icons, buttons, images, and video playback
SDK setup, Gradle integration, AndroidManifest configuration, and first connection to Meta glasses
MockDeviceKit for testing without physical glasses hardware
| 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 Session with Wearables.createSession(...), start it, then attach capabilities such as camera streaming. Session lifecycle and stream 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 | Session ended | Release resources and create a new session if needed |
val session = Wearables.createSession(AutoDeviceSelector()).getOrElse { error ->
throw IllegalStateException(error.description)
}
session.start()
lifecycleScope.launch {
session.state.collect { state ->
when (state) {
DeviceSessionState.STARTED -> onStarted()
DeviceSessionState.PAUSED -> onPaused()
DeviceSessionState.STOPPED -> onStopped()
else -> Unit
}
}
}
Camera streaming has its own state flow after you attach a stream:
STOPPED -> STARTING -> STARTED -> STREAMING -> STOPPING -> STOPPED -> CLOSED
lifecycleScope.launch {
stream.state.collect { state ->
// React to camera capability 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.
DeviceSessionState values you care aboutSessionError and StreamError failures