ARCore for Jetpack XR brings powerful perception capabilities for your app to understand the real world through a variety of APIs. Some of these APIs help you enhance immersive experiences for devices such as XR headsets and wired XR glasses, some help you enhance augmented experiences for devices such as AI glasses, and some help you enhance app experiences for all types of Android XR devices.
For example, you can use ARCore for Jetpack XR to retrieve planar data, anchor content to a fixed location in space, or use a geospatial pose to anchor content to a real-world location.
Add library dependencies
Before you begin using perception features in your XR app, add the necessary dependencies, depending on the type of app experiences you are enhancing with AR.
Access a session
Perception features in ARCore for Jetpack XR rely on a Session, which
uses the Jetpack XR Runtime.
How your app should access a session depends on the types of app experiences that you're enhancing with perception features:
- If your app is enhancing immersive experiences with spatial UI using Jetpack Compose for XR, access a session from Jetpack Compose for XR.
- For all other situations, you can access access a session from Jetpack XR Runtime, which is covered in the following section on this page.
Access a session from Jetpack XR Runtime
To access a session from Jetpack XR Runtime, you'll create it:
To create a session, pass an activity to the create()
method, as shown in the following example:
when (val result = Session.create(this)) { is SessionCreateSuccess -> { val xrSession = result.session // ... } else -> TODO(/* A different unhandled exception was thrown. */) }
When a session's activity is destroyed, all AR content associated with that session is destroyed, and the session is no longer valid.
Configure a session
Some features might be disabled by default and must be configured in order to
function. To configure a session, use configure() and specify the
configuration options that your Session needs. For details about
the required configuration for different AR features, see the corresponding
pages for each AR feature.
Next steps
After your app has a session, explore the ways you can use it to enhance app experiences for different XR devices:
- Detect planes using ARCore for Jetpack XR
- Create anchors with ARCore for Jetpack XR
- Work with hands using ARCore for Jetpack XR
- Incorporate the head position in your app with ARCore for Jetpack XR
- Incorporate face tracking in your app with ARCore for Jetpack XR
- Retrieve depth information in your app with ARCore for Jetpack XR
- Track a device's pose using ARCore for Jetpack XR
- Work with geospatial poses using ARCore for Jetpack XR