Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
facebook avatar

Session Lifecycle

  • 5 installs
  • 340 repo stars
  • Updated August 3, 2026
  • facebook/meta-wearables-dat-android

Manages DAT SDK Android session and stream state including start, pause, resume, stop transitions and device-availability monitoring.

About

Explains how to create and manage DAT session and stream lifecycles on Android, tracking states from IDLE through STOPPED. Android developers use it to handle pause/resume behavior and device-availability changes correctly.

  • Session state table with per-state app actions
  • Distinguishes session lifecycle from stream lifecycle

Session Lifecycle by the numbers

  • 5 all-time installs (skills.sh)
  • Ranked #828 of 1,039 Mobile Development skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/facebook/meta-wearables-dat-android --skill session-lifecycle

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs5
repo stars340
Last updatedAugust 3, 2026
Repositoryfacebook/meta-wearables-dat-android

What it does

Manages DAT SDK Android session and stream state including start, pause, resume, stop transitions and device-availability monitoring.

Files

SKILL.mdMarkdownGitHub ↗

Session Lifecycle (Android)

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.

Session states

StateMeaningApp action
IDLESession created, not started yetCall session.start()
STARTINGConnecting to the deviceShow loading UI
STARTEDSession active and ready for capabilitiesAdd or use capabilities
PAUSEDSession temporarily suspendedKeep state, wait for resume or stop
STOPPINGSession is shutting downStop user work and wait
STOPPEDSession endedRelease resources and create a new session if needed

Observe session state

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
        }
    }
}

Stream state

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
    }
}

Common transitions

The SDK may pause or stop a session when:

  • Another experience takes over the device
  • The user removes or folds the glasses
  • Bluetooth connectivity drops
  • The user unregisters the app or revokes needed access

Pause and resume

When a session is paused:

  • The device connection may remain active
  • Attached capabilities stop doing useful work
  • Your app should wait for the next observed session state instead of trying to force a restart

Device availability

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.

Checklist

  • [ ] Handle all DeviceSessionState values you care about
  • [ ] Observe stream state separately from session state
  • [ ] Release resources only after stop or close
  • [ ] Recreate sessions after terminal stops instead of reusing dead ones
  • [ ] Surface typed SessionError and StreamError failures

Links

Related skills

Mobile Developmentintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.