session-lifecycle

โดย facebook

สถานะเซสชัน สถานะสตรีม พฤติกรรมการหยุดชั่วคราวและดำเนินการต่อ และการตรวจสอบความพร้อมใช้งานของอุปกรณ์

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

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

Skills เพิ่มเติมจาก facebook

binary-size-analysis
facebook
วิเคราะห์การเปลี่ยนแปลงขนาดไบนารีต่อคอมมิตของ shared library hermesvm ในช่วงของ git commit สร้างรายงาน markdown พร้อมขนาดต่อคอมมิตและตารางสรุปการเพิ่มขึ้นและลดลงที่สำคัญ
official
modify-jsi-features
facebook
คู่มือสำหรับการเพิ่มฟังก์ชันการทำงาน JSI ใหม่ให้กับเลเยอร์ JavaScript Interface (JSI) ใช้เมื่อผู้ใช้ขอให้เพิ่ม สร้าง หรือนำเมธอดหรือฟีเจอร์ใหม่ไปใช้ใน…
official
non-interactive-git-rebase
facebook
ใช้เมื่อต้องการจัดลำดับใหม่ แยก ลบ หรือแก้ไข git commits ที่ไม่ใช่ commit ล่าสุด โดยไม่ต้องเข้าถึงตัวแก้ไขแบบโต้ตอบ ครอบคลุมการ rebase ผ่านโปรแกรม…
official
click-target
facebook
ค้นหาและคลิกวัตถุเป้าหมายใน XR ใช้เมื่อทดสอบการโต้ตอบ UI การคลิกปุ่ม หรือตรวจสอบว่าองค์ประกอบที่สามารถโต้ตอบได้ทำงานอย่างถูกต้อง
official
iwsdk-planner
facebook
คู่มือการวางแผนโครงการ IWSDK และแนวทางปฏิบัติที่ดีที่สุด ใช้เมื่อวางแผนฟีเจอร์ IWSDK ใหม่ ออกแบบระบบ/ส่วนประกอบ ทบทวนสถาปัตยกรรมโค้ด IWSDK หรือเมื่อ...
official
iwsdk-ui-panel
facebook
พัฒนาและปรับปรุงแผง UI ของ IWSDK อย่างมีประสิทธิภาพ ใช้เมื่อทำงานกับคอมโพเนนต์ PanelUI แก้ไขปัญหาเค้าโครง UI หรือปรับปรุงการออกแบบ UI ในแอปพลิเคชัน IWSDK
official
test-all
facebook
ตัวประสานการทดสอบแบบขนาน รันชุดทดสอบทั้งหมด 9 ชุดพร้อมกันผ่าน Task sub-agents และ iwsdk CLI จัดการการสร้าง การตั้งค่าตัวอย่าง เซิร์ฟเวอร์สำหรับพัฒนา การเปิดตัวเอเจนต์…
official
test-audio
facebook
ทดสอบระบบเสียง (การโหลด AudioSource, สถานะการเล่น, การหยุด, เสียงเชิงพื้นที่) กับตัวอย่างเสียงโดยใช้ iwsdk CLI
official