# 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)

*** ** * ** ***


```
public final class ActivitySpace extends SpaceEntity
```

<br />

|---|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||||
| ↳ | [androidx.xr.scenecore.BaseScenePose](https://developer.android.com/reference/androidx/xr/scenecore/BaseScenePose) ||||
|   | ↳ | [androidx.xr.scenecore.Entity](https://developer.android.com/reference/androidx/xr/scenecore/Entity) |||
|   |   | ↳ | [androidx.xr.scenecore.SpaceEntity](https://developer.android.com/reference/androidx/xr/scenecore/SpaceEntity) ||
|   |   |   | ↳ | [androidx.xr.scenecore.ActivitySpace](https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace) |

*** ** * ** ***

ActivitySpace is a `https://developer.android.com/reference/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 methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace#addBoundsChangedListener(java.util.function.Consumer)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d> listener)` 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. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace#addBoundsChangedListener(java.util.concurrent.Executor,java.util.function.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html callbackExecutor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d> listener )` 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. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace#addOriginChangedListener(java.lang.Runnable)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Runnable.html listener)` Adds a listener to be called when the ActivitySpace's origin has moved or changed, typically due to an internal system event. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace#addOriginChangedListener(java.util.concurrent.Executor,java.lang.Runnable)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Runnable.html listener )` Adds a listener to be called when the ActivitySpace's origin has moved or changed, typically due to an internal system event. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d` | `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace#getBounds()()` The current bounds of this ActivitySpace. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox` | `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace#getRecommendedContentBoxInFullSpace()()` A recommended box for content to be placed in when in Full Space. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace#removeBoundsChangedListener(java.util.function.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d> listener )` Releases the given `https://developer.android.com/reference/java/util/function/Consumer.html` from receiving updates when the ActivitySpace's boundary changes. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace#removeOriginChangedListener(java.lang.Runnable)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Runnable.html listener)` Removes the previously-added listener. |

### Inherited methods

From [androidx.xr.scenecore.BaseScenePose](https://developer.android.com/reference/androidx/xr/scenecore/BaseScenePose) `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Pose` `https://developer.android.com/reference/androidx/xr/scenecore/BaseScenePose#getPoseInActivitySpace()()`

The current `https://developer.android.com/reference/androidx/xr/runtime/math/Pose` relative to the activity space root.
`https://developer.android.com/reference/androidx/xr/scenecore/HitTestResult` `https://developer.android.com/reference/androidx/xr/scenecore/BaseScenePose#hitTest(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 origin, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 direction)`

Perform a hit test from the specified origin in the specified direction into the Scene.
`https://developer.android.com/reference/androidx/xr/scenecore/HitTestResult` `https://developer.android.com/reference/androidx/xr/scenecore/BaseScenePose#hitTest(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3,kotlin.Int)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 origin,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 direction,
int hitTestFilter
)`

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

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

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

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

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/androidx/xr/scenecore/Entity) `final void` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#addChild(androidx.xr.scenecore.Entity)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Entity child)`

Sets an Entity to be a child of this Entity in the scene graph.
`final boolean` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#addComponent(androidx.xr.scenecore.Component)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Component component)`

Adds a Component to this Entity.
`final @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0, to = 1.0) float` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#getAlpha(androidx.xr.scenecore.Space)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Space relativeTo)`

Returns the alpha transparency set for this Entity, relative to given Space.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Entity>` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#getChildren()()`

Provides the list of all children of this entity.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Component>` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#getComponents()()`

Retrieves all components attached to this Entity.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull T>` `<T extends https://developer.android.com/reference/androidx/xr/scenecore/Component> https://developer.android.com/reference/androidx/xr/scenecore/Entity#getComponentsOfType(java.lang.Class)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> type)`

Retrieves all Components of the given type `https://developer.android.com/reference/androidx/xr/scenecore/Entity#getComponentsOfType(java.lang.Class)` and its subtypes attached to this Entity.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#getContentDescription()()`

Alternate text for this Entity to be consumed by Accessibility systems.
`final boolean` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#isEnabled(kotlin.Boolean)(boolean includeParents)`

Returns the enabled status of this Entity.
`final void` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#removeAllComponents()()`

Remove all components from this Entity.
`final void` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#removeComponent(androidx.xr.scenecore.Component)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Component component)`

Removes the given Component from this Entity.
`final void` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#setAlpha(kotlin.Float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0, to = 1.0) float alpha)`

Sets the alpha transparency of the Entity relative to the parent Space.
`final void` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#setContentDescription(kotlin.CharSequence)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html value)`

Alternate text for this Entity to be consumed by Accessibility systems.
`final void` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#setEnabled(kotlin.Boolean)(boolean enabled)`

Sets the local enabled state of this Entity.
From [androidx.xr.scenecore.SpaceEntity](https://developer.android.com/reference/androidx/xr/scenecore/SpaceEntity) `https://developer.android.com/reference/androidx/xr/scenecore/Entity` `https://developer.android.com/reference/androidx/xr/scenecore/SpaceEntity#getParent()()`

Throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` if called.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Pose` `https://developer.android.com/reference/androidx/xr/scenecore/SpaceEntity#getPose(androidx.xr.scenecore.Space)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Space relativeTo)`

Returns the pose of the `SpaceEntity` relative to the specified coordinate space.
`float` `https://developer.android.com/reference/androidx/xr/scenecore/SpaceEntity#getScale(androidx.xr.scenecore.Space)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Space relativeTo)`

Returns the scale of the `SpaceEntity` relative to the specified coordinate space.
`void` `https://developer.android.com/reference/androidx/xr/scenecore/SpaceEntity#setParent(androidx.xr.scenecore.Entity)(https://developer.android.com/reference/androidx/xr/scenecore/Entity <unused var>)`

Throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` if called.
`void` `https://developer.android.com/reference/androidx/xr/scenecore/SpaceEntity#setPose(androidx.xr.runtime.math.Pose,androidx.xr.scenecore.Space)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Pose pose, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Space relativeTo)`

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

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

## Public methods

### addBoundsChangedListener

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

```
public final void addBoundsChangedListener(@NonNull Consumer<@NonNull FloatSize3d> listener)
```

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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d> listener` | 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)

```
public final void addBoundsChangedListener(
    @NonNull Executor callbackExecutor,
    @NonNull Consumer<@NonNull FloatSize3d> listener
)
```

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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html callbackExecutor` | The executor on which to invoke the listener on. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d> listener` | 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)

```
public final void addOriginChangedListener(@NonNull Runnable listener)
```

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/androidx/xr/scenecore/ScenePose` that is not a child of ActivitySpace, such as `https://developer.android.com/reference/androidx/xr/scenecore/AnchorSpace`, will have a different position relative to the `https://developer.android.com/reference/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Runnable.html listener` | The listener to register. |

### addOriginChangedListener

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

```
public final void addOriginChangedListener(
    @NonNull Executor executor,
    @NonNull Runnable listener
)
```

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/androidx/xr/scenecore/ScenePose` that is not a child of ActivitySpace, such as `https://developer.android.com/reference/androidx/xr/scenecore/AnchorSpace`, will have a different position relative to the `https://developer.android.com/reference/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | The `https://developer.android.com/reference/java/util/concurrent/Executor.html` on which to run the listener. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Runnable.html listener` | The listener to register. |

### getBounds

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

```
public final @NonNull FloatSize3d getBounds()
```

The current bounds of this ActivitySpace.

### getRecommendedContentBoxInFullSpace

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

```
public final @NonNull BoundingBox getRecommendedContentBoxInFullSpace()
```

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/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.

### removeBoundsChangedListener

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

```
public final void removeBoundsChangedListener(
    @NonNull Consumer<@NonNull FloatSize3d> listener
)
```

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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d> listener` | 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)

```
public final void removeOriginChangedListener(@NonNull Runnable listener)
```

Removes the previously-added listener.

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