Generated banner for Projected Hardware
Generated logo for Projected Hardware

Projected Hardware

Android (Google)OfficialCreated by Google LLCDistributed by Android (Google)

  • Skill
  • Tool integration
  • Software development
  • Apache-2.0
  • No issues found

From the author

Provides instructions and workflows for accessing and managing hardware on Android XR projected devices, such as audio glasses and display glasses. Use this skill when building experiences for intelligent eyewear in an Android app and you need to access device hardware like the camera and microphone, handle glasses-specific runtime permissions, or manage connection lifecycles using projected context.
— the description by Google LLC

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

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/android/projected-hardware/download
  2. Unzip 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 compileSdk of 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

Files

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 stateDevice statusDescription
INITIALIZEDCreatedThe lifecycle object is created but not yet observed.
CREATEDInactiveThe service is connected, but the user is not wearing the device.
STARTEDActiveThe user is wearing the device.
DESTROYEDDisconnectedThe device is disconnected or the service connection is lost.
RESUMEDN/AThe 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.isProjectedDeviceConnected to verify that the projected device is connected to the host device.

  • Obtain a ProjectedContext : Only call ProjectedContext.createProjectedDeviceContext after verifying the connection, and make sure you pass this context into your XrDevice instance.

  • Handle context invalidation : A new deviceId is generated every time a projected device connects. Once the state reaches DESTROYED, the current ProjectedContext is 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 STARTED back to CREATED. The CREATED state 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