androidx.xr.compose.platform

Interfaces

SpaceRequestResult

Represents the expected result of a space request.

SpatialCapabilities

Provides information and functionality related to the spatial capabilities of the application.

SpatialConfiguration

Provides information and functionality related to the spatial configuration of the application.

Classes

SpaceRequestResult.Error

The space transition failed due to a system error or exception.

Objects

SpaceRequestResult.Success

The application successfully transitioned to the requested space.

SpaceRequestResult.Unsupported

The device or environment does not support XR space transitions.

Extension functions summary

suspend SpaceRequestResult

Request that the system places the application into full space mode.

suspend SpaceRequestResult

Request that the system places the application into home space mode.

Top-level properties summary

ProvidableCompositionLocal<Session?>

A composition local that provides the current Jetpack XR Session.

ProvidableCompositionLocal<SpatialCapabilities>

Provides the current SpatialCapabilities that are currently available to the application.

ProvidableCompositionLocal<SpatialConfiguration>

Provides the current SpatialConfiguration.

Extension functions

ComponentActivity.requestFullSpace

suspend fun ComponentActivity.requestFullSpace(): SpaceRequestResult

Request that the system places the application into full space mode.

In full space, this application will be the only application in the visible space, its spatial capabilities will be expanded, and its physical bounds will expand to fill the entire virtual space.

This suspend function initiates an asynchronous OS-level space change and will resume with SpaceRequestResult.Success once the application has successfully entered full space. If the device does not support XR spaces, it will resume immediately with SpaceRequestResult.Unsupported.

Note: Because Full Space Mode and Home Space Mode changes are OS-level system changes, the space switch cannot be aborted mid-flight once initiated. Cancelling this coroutine unregisters the bounds listener but does not interrupt the ongoing space change. If requestFullSpace or requestHomeSpace is called again before this request completes, the coroutine suspended on this call will be cancelled with a CancellationException.

See modes in XR.

Returns
SpaceRequestResult

SpaceRequestResult.Success if the application successfully enters full space, SpaceRequestResult.Unsupported if the device does not support XR spaces, or SpaceRequestResult.Error if a system error occurs.

ComponentActivity.requestHomeSpace

suspend fun ComponentActivity.requestHomeSpace(): SpaceRequestResult

Request that the system places the application into home space mode.

In home space, the visible space may be shared with other applications; however, applications in home space will have their spatial capabilities and physical bounds limited.

This suspend function initiates an asynchronous OS-level space change and will resume with SpaceRequestResult.Success once the application has successfully entered home space. If the device does not support XR spaces, it will resume immediately with SpaceRequestResult.Unsupported.

Note: Because Full Space Mode and Home Space Mode changes are OS-level system changes, the space switch cannot be aborted mid-flight once initiated. Cancelling this coroutine unregisters the bounds listener but does not interrupt the ongoing space change. If requestFullSpace or requestHomeSpace is called again before this request completes, the coroutine suspended on this call will be cancelled with a CancellationException.

See modes in XR.

Returns
SpaceRequestResult

SpaceRequestResult.Success if the application successfully enters home space, SpaceRequestResult.Unsupported if the device does not support XR spaces, or SpaceRequestResult.Error if a system error occurs.

Top-level properties

LocalSession

val LocalSessionProvidableCompositionLocal<Session?>

A composition local that provides the current Jetpack XR Session.

In non-XR environments, this composition local will return null.

LocalSpatialCapabilities

val LocalSpatialCapabilitiesProvidableCompositionLocal<SpatialCapabilities>

Provides the current SpatialCapabilities that are currently available to the application.

The SpatialCapabilities represents a set of inherent permissions that the application may have depending on the context. For example, in home space mode, the app may not have the ability to create spatial UI; however, in full space mode, the application may have this capability.

LocalSpatialConfiguration

val LocalSpatialConfigurationProvidableCompositionLocal<SpatialConfiguration>

Provides the current SpatialConfiguration.

The behavior of the configuration object will depend on whether the system XR Spatial feature is enabled.