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

The SDK is published to Maven Central under the com.meta.wearable group, so the mavenCentral() repository already declared in settings.gradle.kts is all that is needed. No access token is required.

Step 1: Declare dependencies

In libs.versions.toml:

[versions]
mwdat = "1.0.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 2: 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 3: Initialize the SDK

import android.util.Log
import com.meta.wearable.dat.core.Wearables

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

Step 4: Register and create a session

Registration must complete before a session can start. Observe Wearables.registrationState and wait for RegistrationState.REGISTERED.

import com.meta.wearable.dat.core.Wearables
import com.meta.wearable.dat.core.selectors.AutoDeviceSelector
import com.meta.wearable.dat.core.session.DeviceSession
import com.meta.wearable.dat.core.session.DeviceSessionState

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

fun startSession() {
    Wearables.createSession(AutoDeviceSelector()).fold(
        onSuccess = { session ->
            lifecycleScope.launch {
                session.errors.collect { error -> showError(error.description) }
            }
            lifecycleScope.launch {
                session.state.collect { state ->
                    if (state == DeviceSessionState.STARTED) {
                        addCameraStreaming(session)
                    }
                }
            }
            // Fire-and-forget: returns Unit and reports failures through session.errors.
            session.start()
        },
        onFailure = { error, _ -> showError(error.description) },
    )
}

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 5: Add camera streaming

Call this only once the session reports DeviceSessionState.STARTED; adding a capability earlier fails with DeviceSessionError.SESSION_IDLE.

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

fun addCameraStreaming(session: DeviceSession) {
    session.addCamera(
        StreamConfiguration(videoQuality = VideoQuality.MEDIUM, frameRate = 24),
    ).fold(
        onSuccess = { camera ->
            camera.stream.start().onFailure { error, _ -> showError(error.description) }
        },
        onFailure = { error, _ -> showError(error.description) },
    )
}

Camera access also needs the DAT camera permission; see the permissions-registration skill.

Next steps

  • camera-streaming — Stream capability, video frames, photo capture
  • mockdevice-testing — Test without hardware
  • session-lifecycle — Handle session and stream state changes
  • permissions-registration — Registration and permission flows
  • display-access — Render content on Meta Ray-Ban Display glasses
  • Full Android API reference

facebook의 다른 스킬

gc-safe-coding
facebook
전체 설명과 근거는 doc/GCSafeCoding.md를 참조하십시오.
app-review-prep
facebook
Meta 앱을 App Review용으로 준비합니다 — 현재 상태, 미해결 요구 사항, 부여된 권한, 제출 내역을 확인합니다. 앱을 제출하기 전에 사용하세요…
api-health
facebook
Meta 앱의 API 상태를 모니터링합니다 — 비율 제한, 호출량, API 지원 중단 여부를 확인합니다. 트래픽 제한을 진단하거나, 용량을 계획하거나, API 버전 변경에 대비하는 데 사용합니다…
debug-webhooks
facebook
Meta 앱의 웹훅 문제를 해결합니다 — 활성 구독을 검사하고, 잘못된 구성을 식별하며, 테스트 페이로드를 전송하여 전달을 확인합니다. 다음과 같은 경우에 사용하세요…
api-integration
facebook
개발자가 Meta API 통합을 처음부터 설정하도록 안내합니다 — 적절한 API를 찾아내고, 설정 가이드, 인증 요구 사항 등을 가져옵니다…
webhook-setup
facebook
Meta 앱용 웹훅을 처음부터 끝까지 설정하세요 — 사용 가능한 주제를 탐색하고, 필드를 구독하고, 테스트 페이로드로 검증합니다. 웹훅을 구성할 때 사용하세요…
test-ui
facebook
iwsdk CLI를 사용하여 포크 예제에 대해 Test UI 시스템(PanelUI, ScreenSpace)을 테스트합니다.
flags
facebook
React 릴리스 채널 간 기능 플래그 상태를 검사하고 비교합니다. 모든 채널(www, www-modern, canary, next, experimental, rn 변형)의 플래그를 보거나 --diff로 특정 채널을 비교합니다. 출력 형식은 기본 테이블 보기, CSV 내보내기, 정리 상태 그룹화를 포함합니다. 플래그 상태는 기호로 표시됩니다: 활성화(✅), 비활성화(❌), 변형 테스트(🧪), 프로파일링 전용(📊). 일반적인 실수: __VARIANT__ 플래그는 www에서 두 상태 모두 테스트되며, --diff를 사용하여 의미 있는 차이를 찾습니다...