# SpatialActivityPanelController

Artifact: [androidx.xr.compose:compose](https://developer.android.com/jetpack/androidx/releases/xr-compose) [View Source](https://cs.android.com/search?q=file:androidx/xr/compose/subspace/SpatialActivityPanel.android.kt+class:androidx.xr.compose.subspace.SpatialActivityPanelController) Added in [1.0.0-beta02](https://developer.android.com/jetpack/androidx/releases/xr-compose#1.0.0-beta02)


```
class SpatialActivityPanelController
```

<br />

*** ** * ** ***

A state holder and controller for managing the embedded `https://developer.android.com/reference/android/app/Activity.html` lifecycle within a `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/SpatialActivityPanel.composable#SpatialActivityPanel(androidx.xr.compose.subspace.SpatialActivityPanelController,androidx.xr.compose.subspace.layout.SubspaceModifier,androidx.xr.compose.subspace.layout.SpatialShape)`.

This controller acts as a bridge between standard imperative intent dispatching and the declarative Compose XR environment. It maintains a queue of `https://developer.android.com/reference/android/content/Intent.html`s. If the associated `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/SpatialActivityPanel.composable#SpatialActivityPanel(androidx.xr.compose.subspace.SpatialActivityPanelController,androidx.xr.compose.subspace.layout.SubspaceModifier,androidx.xr.compose.subspace.layout.SpatialShape)` is present in the composition and actively listening, incoming Intents are dispatched immediately. If the panel is not yet ready, Intents are queued and will be drained sequentially the moment the panel binds to this controller.

This class is thread-safe and safe to call from background threads (e.g. calling `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/SpatialActivityPanelController#startActivity(android.content.Intent)` concurrently). It uses non-blocking concurrent structures rather than locks to prevent blocking the main recomposition thread.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/SpatialActivityPanelController#SpatialActivityPanelController(android.content.Intent)(initialIntent: https://developer.android.com/reference/android/content/Intent.html)` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/SpatialActivityPanelController#startActivity(android.content.Intent)(intent: https://developer.android.com/reference/android/content/Intent.html)` Dispatches an `https://developer.android.com/reference/android/content/Intent.html` to the `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/SpatialActivityPanel.composable#SpatialActivityPanel(androidx.xr.compose.subspace.SpatialActivityPanelController,androidx.xr.compose.subspace.layout.SubspaceModifier,androidx.xr.compose.subspace.layout.SpatialShape)`. |

## Public constructors

### SpatialActivityPanelController

Added in [1.0.0-beta02](https://developer.android.com/jetpack/androidx/releases/xr-compose#1.0.0-beta02)

```
SpatialActivityPanelController(initialIntent: Intent)
```

| Parameters |
|---|---|
| `initialIntent: https://developer.android.com/reference/android/content/Intent.html` | The initial `https://developer.android.com/reference/android/content/Intent.html` to queue for execution inside the activity panel. |

## Public functions

### startActivity

Added in [1.0.0-beta02](https://developer.android.com/jetpack/androidx/releases/xr-compose#1.0.0-beta02)

```
fun startActivity(intent: Intent): Unit
```

Dispatches an `https://developer.android.com/reference/android/content/Intent.html` to the `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/SpatialActivityPanel.composable#SpatialActivityPanel(androidx.xr.compose.subspace.SpatialActivityPanelController,androidx.xr.compose.subspace.layout.SubspaceModifier,androidx.xr.compose.subspace.layout.SpatialShape)`.

If the panel is active and bound to this controller, the intent is processed immediately. Otherwise, the intent is placed in a pending queue and will be processed once the panel becomes active.

| Parameters |
|---|---|
| `intent: https://developer.android.com/reference/android/content/Intent.html` | The `https://developer.android.com/reference/android/content/Intent.html` to launch in the activity panel. |