Different types of AI glasses have different capabilities. After planning how you'll support different types of AI devices, you can check for device capabilities at runtime to provide the best experience for a user's device.
Check whether a device has a display
Some AI glasses have a display where your app can show UIs built with Jetpack Compose Glimmer. The following example shows how to check whether a glasses device has a display:
val projectedDeviceController = ProjectedDeviceController.create(activity)
if (projectedDeviceController.capabilities.contains(CAPABILITY_VISUAL_UI)) {
// Set up UX state machine for AI glasses that have a display.
} else {
// Set up UX state machine for AI glasses that don't have a display.
}
React to display state changes
On AI glasses with a display, the display can time out or the user can turn off
the display. To design activities that run whether the display is on or off,
use addPresentationModeChangedListener to be notified when the display
state changes. You can tune your activity for the appropriate amount of
audio information depending on display state.
ProjectedDisplayController.create(activity).addPresentationModeChangedListener {
presentationModeFlags ->
val areVisualsOff = !presentationModeFlags.hasPresentationMode(VISUALS_ON)
}
Keep the display on
On AI glasses with a display, you can request that the system keep the screen on
and prevent the screen from timing out using addLayoutParamsFlags.
var projectedDisplayController = ProjectedDisplayController.create(activity)
projectedDisplayController.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)