Transition from Home Space to Full Space

A user can experience your app in two modes, Home Space or Full Space. In Home Space, a user is able to multitask with your app running side by side with other apps. In Full Space, your app takes center stage as the focus of the user's experience with full access to the immersive capabilities of Android XR.

Spatialization is currently only supported in Full Space. Your app can transition to Full Space to take advantage of spatial and 3D capabilities. When your app has focus, you can transition between these modes by requesting the corresponding mode from the XR session.

Your app opens in Home Space by default unless you specify otherwise as described in the Declare the default mode for launch section.

Transition between Home Space and Full Space

To transition between Home Space and Full Space, you'll need to request the mode of operation from the Session. As shown in the following example, you can use these requests so your user can transition between modes by clicking a button.

@Composable
private fun HomeSpaceFullSpaceToggleButton() {
    val xrSession = checkNotNull(LocalSession.current)

    val uiIsSpatialized = LocalSpatialCapabilities.current.isSpatialUiEnabled
    val toggleModes = if (uiIsSpatialized) {
        { xrSession.requestHomeSpaceMode() }
    } else {
        { xrSession.requestFullSpaceMode() }
    }

    IconButton(
        onClick = {
            toggleModes()
        }
    ) {
        Icon(
            painter = painterResource(id = drawable),
            contentDescription = stringResource(contentDescription)
        )
    }
}

See the design guidance to learn more about Home space to Full space and how to best transition between the two.

Declare the default mode for launch

To choose whether your app launches in Home Space or Full Space, add the following lines to your Android Manifest file:

// Launch in Full Space:
<property
   android:name="android.window.PROPERTY_XR_ACTIVITY_START_MODE"
   android:value="XR_ACTIVITY_START_MODE_FULL_SPACE_MANAGED" />

// Or, launch in Home Space:
<property
   android:name="android.window.PROPERTY_XR_ACTIVITY_START_MODE"
   android:value="XR_ACTIVITY_START_MODE_HOME_SPACE_MANAGED" />

See also