Projected Hardware
Android (Google)OfficialCreated by Google LLCDistributed by Android (Google)
- Skill
- Tool integration
- Software development
- Apache-2.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides the necessary patterns for Android developers to interact with hardware components on connected XR devices, such as audio and display glasses. It focuses on the use of ProjectedContext to manage device lifecycles, handle hardware-specific permissions, and ensure stable connections between the host phone and the wearable hardware.
What it does
- Explains how to obtain and use a ProjectedContext for hardware access.
- Provides patterns for monitoring connection states between the host phone and XR glasses.
- Outlines the requirements for declaring and requesting runtime permissions for glasses hardware.
- Details how to manage resource lifecycles based on device availability and connection status.
- Offers guidance on integrating with system services like CameraManager for glasses-specific hardware.
When to use it
- When developing Android applications that need to access cameras or microphones on connected XR eyewear.
- When you need to implement robust connection monitoring to handle device disconnects or removal.
- When you need to manage runtime permissions specifically for projected XR hardware.
- When your app needs to distinguish between phone-based hardware and connected glasses-based hardware.
Advantages
- Ensures stable hardware interaction by leveraging the official ProjectedContext lifecycle management.
- Provides clear patterns for handling the dynamic nature of wearable device connectivity.
- Helps developers correctly implement Android runtime permissions for XR-specific hardware.
Usage examples
- “How do I access the camera on connected audio glasses in my Android app?”
- The skill provides the implementation pattern using ProjectedContext to initialize system services like CameraManager specifically for the connected glasses.
- “How can I tell if the user is currently wearing their display glasses?”
- The skill explains how to use the XR Device Availability API to monitor Lifecycle.State and determine if the device is active, inactive, or disconnected.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/android/projected-hardware/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip projected-hardware.zip -d .agents/skills
Documentation by Google LLC
Prerequisites
You must use a
compileSdkof 36 or higher.
Connection and lifecycle management
Intelligent eyewear hardware is only accessible while the glasses are connected
to the host phone. Monitor connection state and manage resource lifecycles using
ProjectedContext. You must read
Understand projected activities and projected contexts to understand
how to get a projected context and how to manage its lifecycle.
Request glasses hardware permissions
Hardware permissions and opt-in : You must read Request hardware permissions to understand how to declare camera and microphone runtime permissions in the Android Manifest file, request runtime permissions in different scenarios, and handle permission results.
Glasses hardware access and capabilities
Camera capture and CameraX : You must read Capture an image with the glasses' camera to understand the implementation patterns for capturing a photo with the glasses' camera using a
ProjectedContext.
Files
- ATTRIBUTION.mdAdded by AutoGineer957 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md2.0 KiB
- references/android/develop/xr/jetpack-xr-sdk/access-hardware-projected-context.md25.9 KiB
- references/android/develop/xr/jetpack-xr-sdk/glasses/check-availability.md4.7 KiB
- references/android/develop/xr/jetpack-xr-sdk/glasses/support-different-types.md8.3 KiB
- references/android/develop/xr/jetpack-xr-sdk/request-hardware-permissions.md9.1 KiB
references/android/develop/xr/jetpack-xr-sdk/glasses/check-availability.md
<br />
Applicable XR devices This guidance helps you build experiences for these types of XR devices. Learn about XR device types → Image: untitled Audio &
Display Glasses Learn about XR device types →
<br />
As a user goes through their day, their audio glasses or display glasses might
lose their connection to the host device (such as the user's phone) or their
glasses might be temporarily unavailable if they take their glasses off. To
account for these kinds of changes in device availability, your app can use the
XR Device Availability API, which consolidates device availability signals into
the standard Android Lifecycle.State values. Use this API to help manage
audio routing, hotword activation, and to know when to expect user input based
on when the glasses are available.
Understand lifecycle states
The following table lists how device availability signals map to the
Lifecycle.State values.
| Lifecycle state | Device status | Description |
|---|---|---|
INITIALIZED | Created | The lifecycle object is created but not yet observed. |
CREATED | Inactive | The service is connected, but the user is not wearing the device. |
STARTED | Active | The user is wearing the device. |
DESTROYED | Disconnected | The device is disconnected or the service connection is lost. |
RESUMED | N/A | The device lifecycle doesn't currently use or emit this state. |
Check and monitor device availability
To check and monitor a device's availability, you'll use a projected context together with the lifecycle state to determine how your app should handle each case:
// In your phone activity or service, check for projected device connection state before
// attempting to create a projected device context and get the device lifecycle.
ProjectedContext.isProjectedDeviceConnected(context, currentCoroutineContext())
.flatMapLatest { isConnected ->
if (isConnected) {
try {
// Create the projected device context on connection
val projectedContext = ProjectedContext.createProjectedDeviceContext(context)
val xrDevice = XrDevice.getCurrentDevice(projectedContext)
// Get the device lifecycle
xrDevice.getLifecycle().currentStateFlow
} catch (e: IllegalStateException) {
flowOf(Lifecycle.State.DESTROYED)
}
} else {
flowOf(Lifecycle.State.DESTROYED)
}
}
.collect { state ->
when (state) {
Lifecycle.State.STARTED -> { /* Device is available (worn) */ }
Lifecycle.State.CREATED -> { /* Device is unavailable (not worn) */ }
Lifecycle.State.DESTROYED -> { /* Device is disconnected from host phone */ }
else -> { /* Handle other states */ }
}
}
}<br />
Key points about the code
Check for a connection : Before accessing the device lifecycle, call
ProjectedContext.isProjectedDeviceConnectedto verify that the projected device is connected to the host device.Obtain a
ProjectedContext: Only callProjectedContext.createProjectedDeviceContextafter verifying the connection, and make sure you pass this context into yourXrDeviceinstance.Handle context invalidation : A new
deviceIdis generated every time a projected device connects. Once the state reachesDESTROYED, the currentProjectedContextis invalid. Stop using it immediately, and wait for a new connection.Optimize battery and resources : Gracefully handle app functionality based on the lifecycle state to preserve system resources and reduce battery consumption. For example, you should release glasses-specific resources, such as a camera data stream, when the state transitions from
STARTEDback toCREATED. TheCREATEDstate indicates the device is no longer being worn, so stopping these processes is essential to prevent unnecessary battery drain and to promote user privacy.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Google LLC
- Publisher
- Android (Google) (Official)
- Distributed by
- Android (Google)
- Source
- android/skills · xr/projected-hardware · commit bf68e2d
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE.txt)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Google LLC or Android (Google).
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download projected-hardware.zip