# ActivitySpace

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

*** ** * ** ***


```
class ActivitySpace : SpaceEntity
```

<br />

|---|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||||
| ↳ | [androidx.xr.scenecore.BaseScenePose](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose) ||||
|   | ↳ | [androidx.xr.scenecore.Entity](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity) |||
|   |   | ↳ | [androidx.xr.scenecore.SpaceEntity](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity) ||
|   |   |   | ↳ | [androidx.xr.scenecore.ActivitySpace](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ActivitySpace) |

*** ** * ** ***

ActivitySpace is a `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity` used to track the system-managed pose and boundary of the volume associated with a spatialized Activity. The Application cannot directly control this volume, but the system might update it in response to the User moving it or entering or exiting Full Space Mode.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ActivitySpace#addBoundsChangedListener(java.util.function.Consumer)(listener: https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/FloatSize3d>)` Adds the given `https://developer.android.com/reference/java/util/function/Consumer.html` as a listener to be invoked when this ActivitySpace's current boundary changes. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ActivitySpace#addBoundsChangedListener(java.util.concurrent.Executor,java.util.function.Consumer)( callbackExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html, listener: https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/FloatSize3d> )` Adds the given `https://developer.android.com/reference/java/util/function/Consumer.html` as a listener to be invoked when this ActivitySpace's current boundary changes. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ActivitySpace#addOriginChangedListener(java.lang.Runnable)(listener: https://developer.android.com/reference/java/lang/Runnable.html)` Adds a listener to be called when the ActivitySpace's origin has moved or changed, typically due to an internal system event. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ActivitySpace#addOriginChangedListener(java.util.concurrent.Executor,java.lang.Runnable)(executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, listener: https://developer.android.com/reference/java/lang/Runnable.html)` Adds a listener to be called when the ActivitySpace's origin has moved or changed, typically due to an internal system event. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ActivitySpace#removeBoundsChangedListener(java.util.function.Consumer)(listener: https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/FloatSize3d>)` Releases the given `https://developer.android.com/reference/java/util/function/Consumer.html` from receiving updates when the ActivitySpace's boundary changes. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ActivitySpace#removeOriginChangedListener(java.lang.Runnable)(listener: https://developer.android.com/reference/java/lang/Runnable.html)` Removes the previously-added listener. |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/FloatSize3d` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ActivitySpace#bounds()` The current bounds of this ActivitySpace. |
| `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ActivitySpace#recommendedContentBoxInFullSpace()` A recommended box for content to be placed in when in Full Space. |

### Inherited functions

From [androidx.xr.scenecore.BaseScenePose](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose) `open suspend https://developer.android.com/reference/kotlin/androidx/xr/scenecore/HitTestResult?` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#hitTest(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)(origin: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, direction: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3)`

Perform a hit test from the specified origin in the specified direction into the Scene.
`open suspend https://developer.android.com/reference/kotlin/androidx/xr/scenecore/HitTestResult?` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#hitTest(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3,kotlin.Int)(origin: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, direction: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, hitTestFilter: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Creates a hit test from the specified origin in the specified direction into the scene.
`open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#transformDirectionTo(androidx.xr.runtime.math.Vector3,androidx.xr.scenecore.ScenePose)(direction: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, destination: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ScenePose)`

Transforms a direction from this ScenePose's local space to the destination ScenePose's local space.
`open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#transformPoseTo(androidx.xr.runtime.math.Pose,androidx.xr.scenecore.ScenePose)(pose: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose, destination: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ScenePose)`

Returns a `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` relative to this ScenePose, transformed into a Pose relative to the destination.
`open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#transformPositionTo(androidx.xr.runtime.math.Vector3,androidx.xr.scenecore.ScenePose)(position: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, destination: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ScenePose)`

Transforms a position from this ScenePose's local space to the destination ScenePose's local space.
`open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#transformVectorTo(androidx.xr.runtime.math.Vector3,androidx.xr.scenecore.ScenePose)(vector: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, destination: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ScenePose)`

Transforms a vector from this ScenePose's local space to the destination ScenePose's local space.
From [androidx.xr.scenecore.Entity](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#addChild(androidx.xr.scenecore.Entity)(child: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity)`

Sets an Entity to be a child of this Entity in the scene graph.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#addComponent(androidx.xr.scenecore.Component)(component: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Component)`

Adds a Component to this Entity.
`@https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#getAlpha(androidx.xr.scenecore.Space)(relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space)`

Returns the alpha transparency set for this Entity, relative to given Space.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Component>` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#getComponents()()`

Retrieves all components attached to this Entity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T>` `<T : https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Component> https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#getComponentsOfType(java.lang.Class)(type: https://developer.android.com/reference/java/lang/Class.html<T>)`

Retrieves all Components of the given type `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#getComponentsOfType(java.lang.Class)` and its subtypes attached to this Entity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#isEnabled(kotlin.Boolean)(includeParents: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Returns the enabled status of this Entity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#removeAllComponents()()`

Remove all components from this Entity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#removeComponent(androidx.xr.scenecore.Component)(component: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Component)`

Removes the given Component from this Entity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#setAlpha(kotlin.Float)(alpha: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`

Sets the alpha transparency of the Entity relative to the parent Space.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#setEnabled(kotlin.Boolean)(enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Sets the local enabled state of this Entity.
From [androidx.xr.scenecore.SpaceEntity](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity) `open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity#getPose(androidx.xr.scenecore.Space)(relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space)`

Returns the pose of the `SpaceEntity` relative to the specified coordinate space.
`open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity#getScale(androidx.xr.scenecore.Space)(relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space)`

Returns the scale of the `SpaceEntity` relative to the specified coordinate space.
`open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity#setPose(androidx.xr.runtime.math.Pose,androidx.xr.scenecore.Space)(pose: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose, relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space)`

Throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` if called.
`open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity#setScale(kotlin.Float,androidx.xr.scenecore.Space)(scale: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space)`

Throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` if called.

### Inherited properties

From [androidx.xr.scenecore.BaseScenePose](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose) `open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#poseInActivitySpace()`

The current `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` relative to the activity space root.
From [androidx.xr.scenecore.Entity](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity>` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#children()`

Provides the list of all children of this entity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#contentDescription()`

Alternate text for this Entity to be consumed by Accessibility systems.
From [androidx.xr.scenecore.SpaceEntity](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity) `open https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity?` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpaceEntity#parent()`

Throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` if called.

## Public functions

### addBoundsChangedListener

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

```
fun addBoundsChangedListener(listener: Consumer<FloatSize3d>): Unit
```

Adds the given `https://developer.android.com/reference/java/util/function/Consumer.html` as a listener to be invoked when this ActivitySpace's current boundary changes.

`https://developer.android.com/reference/java/util/function/Consumer.html#accept(T)` will be invoked on the main thread.

| Parameters |
|---|---|
| `listener: https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/FloatSize3d>` | The Consumer to be invoked when this ActivitySpace's current boundary changes. |

### addBoundsChangedListener

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

```
fun addBoundsChangedListener(
    callbackExecutor: Executor,
    listener: Consumer<FloatSize3d>
): Unit
```

Adds the given `https://developer.android.com/reference/java/util/function/Consumer.html` as a listener to be invoked when this ActivitySpace's current boundary changes.

`https://developer.android.com/reference/java/util/function/Consumer.html#accept(T)` will be invoked on the given executor.

| Parameters |
|---|---|
| `callbackExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | The executor on which to invoke the listener on. |
| `listener: https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/FloatSize3d>` | The Consumer to be invoked when this ActivitySpace's current boundary changes. |

### addOriginChangedListener

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

```
fun addOriginChangedListener(listener: Runnable): Unit
```

Adds a listener to be called when the ActivitySpace's origin has moved or changed, typically due to an internal system event.

When this event occurs, any `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ScenePose` that is not a child of ActivitySpace, such as `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/AnchorSpace`, will have a different position relative to the `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ActivitySpace`. Therefore, this listener can be used to indicate when to invalidate any cached information about the relative difference in Pose between ActivitySpace's children and children of non-ActivitySpace ScenePoses.

The callback will be made on the SceneCore executor.

| Parameters |
|---|---|
| `listener: https://developer.android.com/reference/java/lang/Runnable.html` | The listener to register. |

### addOriginChangedListener

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

```
fun addOriginChangedListener(executor: Executor, listener: Runnable): Unit
```

Adds a listener to be called when the ActivitySpace's origin has moved or changed, typically due to an internal system event.

When this event occurs, any `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ScenePose` that is not a child of ActivitySpace, such as `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/AnchorSpace`, will have a different position relative to the `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ActivitySpace`. Therefore, this listener can be used to indicate when to invalidate any cached information about the relative difference in Pose between ActivitySpace's children and children of non-ActivitySpace ScenePoses.

| Parameters |
|---|---|
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | The `https://developer.android.com/reference/java/util/concurrent/Executor.html` on which to run the listener. |
| `listener: https://developer.android.com/reference/java/lang/Runnable.html` | The listener to register. |

### removeBoundsChangedListener

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

```
fun removeBoundsChangedListener(listener: Consumer<FloatSize3d>): Unit
```

Releases the given `https://developer.android.com/reference/java/util/function/Consumer.html` from receiving updates when the ActivitySpace's boundary changes.

All listeners are automatically removed when the ActivitySpace is disposed even if this method is not explicitly called.

| Parameters |
|---|---|
| `listener: https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/FloatSize3d>` | The Consumer to be removed from receiving updates. |

### removeOriginChangedListener

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

```
fun removeOriginChangedListener(listener: Runnable): Unit
```

Removes the previously-added listener.

All listeners are automatically removed when the ActivitySpace is disposed even if this method is not explicitly called.

## Public properties

### bounds

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

```
val bounds: FloatSize3d
```

The current bounds of this ActivitySpace.

### recommendedContentBoxInFullSpace

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

```
val recommendedContentBoxInFullSpace: BoundingBox
```

A recommended box for content to be placed in when in Full Space.

The recommended content box is a static 3D volume that uses the device's field of view (FOV) angles, the system's default launch distance from the user, and the default scale of the system to calculate a box size that is sized to encompass the user's primary field of view.

This size does not change throughout the lifecycle of the application. Furthermore, the recommended content box does not have an independent concept of pose; its position is defined by the origin of this `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ActivitySpace`.

The box is relative to the ActivitySpace's coordinate system. It is not scaled by the ActivitySpace's transform. The dimensions are always in meters. This provides a device-specific default volume that developers can use to size their content appropriately.