一键导入
sample-app-guide
Building a complete DAT app with session creation, camera streaming, and photo capture
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Building a complete DAT app with session creation, camera streaming, and photo capture
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | sample-app-guide |
| description | Building a complete DAT app with session creation, camera streaming, and photo capture |
Build an Android DAT app with registration, sessions, camera streaming, and photo capture.
Pair this with the CameraAccess sample.
AndroidManifest.xml for registration callbacks plus APPLICATION_ID and CLIENT_TOKEN.Wearables in your Application.app/src/main/java/com/example/myapp/
├── MyApplication.kt
├── MainActivity.kt
├── session/
│ └── SessionViewModel.kt
└── ui/
├── RegistrationScreen.kt
└── CameraScreen.kt
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
lifecycleScope.launch {
Wearables.registrationState.collect { state ->
// Update registration UI
}
}
}
fun register() {
Wearables.startRegistration(this)
}
}
class SessionViewModel : ViewModel() {
private var session: Session? = null
private var stream: Stream? = null
fun startCameraSession() {
val createdSession = Wearables.createSession(AutoDeviceSelector()).getOrElse { error ->
throw IllegalStateException(error.description)
}
createdSession.start()
session = createdSession
stream = createdSession.addStream(
StreamConfiguration(videoQuality = VideoQuality.MEDIUM, frameRate = 24),
).getOrElse { error ->
throw IllegalStateException(error.description)
}.also { addedStream ->
addedStream.start().getOrElse { error ->
throw IllegalStateException(error.description)
}
}
}
}
viewModelScope.launch {
stream?.videoStream?.collect { frame ->
// Render preview
}
}
fun capturePhoto() {
viewModelScope.launch {
stream?.capturePhoto()
?.onSuccess { photoData ->
savePhoto(photoData.data)
}
?.onFailure { error, _ ->
showCaptureError(error.description)
}
}
}
fun stopCameraSession() {
stream?.stop()
session?.stop()
stream = null
session = null
}
Use MockDeviceKit to simulate linking glasses, permission state, and camera media without physical hardware. See MockDevice Testing for setup details.
Session 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