getting-started

โดย facebook

การตั้งค่า SDK, การรวม Gradle, การกำหนดค่า AndroidManifest, และการเชื่อมต่อครั้งแรกกับแว่นตา Meta

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

Getting Started with DAT SDK (Android)

Set up the Meta Wearables Device Access Toolkit in an Android app.

Prerequisites

  • Android Studio Flamingo or newer
  • Android 10+ test device with the Meta AI app installed
  • Supported Meta glasses or MockDeviceKit for local testing
  • Developer Mode enabled in the Meta AI app for development builds
  • GitHub personal access token with read:packages scope

Step 1: Add the Maven repository

In settings.gradle.kts:

val localProperties =
    Properties().apply {
        val localPropertiesPath = rootDir.toPath() / "local.properties"
        if (localPropertiesPath.exists()) {
            load(localPropertiesPath.inputStream())
        }
    }

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven {
            url = uri("https://maven.pkg.github.com/facebook/meta-wearables-dat-android")
            credentials {
                username = ""
                password = System.getenv("GITHUB_TOKEN") ?: localProperties.getProperty("github_token")
            }
        }
    }
}

Step 2: Declare dependencies

In libs.versions.toml:

[versions]
mwdat = "0.8.0"

[libraries]
mwdat-core = { group = "com.meta.wearable", name = "mwdat-core", version.ref = "mwdat" }
mwdat-camera = { group = "com.meta.wearable", name = "mwdat-camera", version.ref = "mwdat" }
mwdat-display = { group = "com.meta.wearable", name = "mwdat-display", version.ref = "mwdat" }
mwdat-mockdevice = { group = "com.meta.wearable", name = "mwdat-mockdevice", version.ref = "mwdat" }

In app/build.gradle.kts:

android {
    defaultConfig {
        manifestPlaceholders["mwdat_application_id"] = "0"
        manifestPlaceholders["mwdat_client_token"] = "0"
    }
}

dependencies {
    implementation(libs.mwdat.core)
    implementation(libs.mwdat.camera)
    implementation(libs.mwdat.display)
    implementation(libs.mwdat.mockdevice)
}

Step 3: Configure AndroidManifest.xml

<manifest ...>
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <uses-permission android:name="android.permission.INTERNET" />

    <application ...>
        <meta-data
            android:name="com.meta.wearable.mwdat.APPLICATION_ID"
            android:value="${mwdat_application_id}" />
        <meta-data
            android:name="com.meta.wearable.mwdat.CLIENT_TOKEN"
            android:value="${mwdat_client_token}" />

        <activity android:name=".MainActivity" ...>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="myexampleapp" />
            </intent-filter>
        </activity>
    </application>
</manifest>

APPLICATION_ID and CLIENT_TOKEN are used for app attestation and can be found in the Wearables Developer Center. In Developer Mode, attestation is not used, so the manifest placeholders can both be 0. For production, replace both placeholders with the credentials for your Wearables Developer Center app. Replace myexampleapp with your app's URL scheme.

Step 4: Initialize the SDK

import com.meta.wearable.dat.core.Wearables

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        Wearables.initialize(this)
            .onFailure { error, _ -> error("Failed to initialize DAT: ${error.description}") }
    }
}

Step 5: Register and create a session

import com.meta.wearable.dat.core.Wearables
import com.meta.wearable.dat.core.selectors.AutoDeviceSelector

fun connect(activity: Activity) {
    Wearables.startRegistration(activity)
}

fun startSession() {
    val session = Wearables.createSession(AutoDeviceSelector()).getOrElse { error ->
        throw IllegalStateException(error.description)
    }

    session.start()
}

Observe registration and available devices:

lifecycleScope.launch {
    Wearables.registrationState.collect { state ->
        // Update registration UI
    }
}

lifecycleScope.launch {
    Wearables.devices.collect { devices ->
        // Update the device list
    }
}

Step 6: Add camera streaming

import com.meta.wearable.dat.camera.addStream
import com.meta.wearable.dat.camera.types.StreamConfiguration
import com.meta.wearable.dat.camera.types.VideoQuality

val stream = session.addStream(
    StreamConfiguration(videoQuality = VideoQuality.MEDIUM, frameRate = 24),
).getOrElse { error ->
    throw IllegalStateException(error.description)
}

stream.start().onFailure { error, _ ->
    throw IllegalStateException(error.description)
}

Next steps

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