بنقرة واحدة
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 المهني
| 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 failuresSession 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