Enhance app experiences with perception using ARCore for Jetpack XR

Applicable XR devices
This guidance helps you build experiences for these types of XR devices.
XR Headsets
Wired XR Glasses
Audio &
Display Glasses

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:

Create a session using Jetpack XR Runtime

To create a session, pass a Context to the create() method. This Context can be an Activity on immersive XR devices or mobile devices, or a projected context on Intelligent Eyewear.

Creating an ARCore session can be an expensive task, and should be processed in the background, as shown in the following example:

lifecycleScope.launch {
    when (val result = Session.create(context)) {
        is SessionCreateSuccess -> {
            val xrSession = result.session
            // ...
        }
        else ->
            TODO(/* A different unhandled exception was thrown. */)
    }
}

The create() function can use an optional LifecycleOwner parameter, which allows the session's lifecycle to be managed by a different LifecycleOwner. The LifecycleOwner must begin and end its lifecycle within the scope of the provided context, otherwise the Session may be prone to leaks.

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: