ActivitySpace


class ActivitySpace : BaseEntity


ActivitySpace is an Entity used to track the system-managed pose and boundary of the volume associated with this 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 FullSpace mode.

Summary

Public functions

Unit

Adds the given Consumer as a listener to be invoked when this ActivitySpace's current boundary changes.

Unit
addBoundsChangedListener(
    callbackExecutor: Executor,
    listener: Consumer<Dimensions>
)

Adds the given Consumer as a listener to be invoked when this ActivitySpace's current boundary changes.

Dimensions

Retrieves a copy of the current bounds of this ActivitySpace.

Unit

This function is deprecated. use addBoundsChangedListener(Consumer<Dimensions>)

Unit

Releases the given Consumer from receiving updates when the ActivitySpace's boundary changes.

Unit
setOnSpaceUpdatedListener(
    listener: OnSpaceUpdatedListener?,
    executor: Executor?
)

Registers a listener to be called when the underlying space has moved or changed.

Unit

This function is deprecated. use removeBoundsChangedListener(Consumer<Dimensions>)

Inherited functions

From androidx.xr.scenecore.ActivityPose
abstract Pose

Returns the activity space pose for this ActivityPose.

abstract Pose
transformPoseTo(pose: Pose, destination: ActivityPose)

Returns a pose relative to this ActivityPose transformed into a pose relative to the destination.

From androidx.xr.scenecore.BaseEntity
open Unit
addChild(child: Entity)

Sets an Entity to be represented in this coordinate space.

open Boolean
addComponent(component: Component)

Adds a Component to this Entity.

open Unit

Disposes of any system resources held by this Entity, and transitively calls dispose() on all its children.

open Float

Returns the global alpha of this entity computed by multiplying the parent's global alpha to this entity's local alpha.

open Float

Returns the alpha transparency set for this Entity.

open List<Component>

Retrieves all components attached to this Entity.

open List<T>

Retrieves all Components of the given type T and its sub-types attached to this Entity.

open Entity?

Returns the parent of this Entity.

open Pose

Returns the pose for this entity, relative to its parent.

open Float

Returns the local scale of this entity, not inclusive of the parent's scale.

open Dimensions

Returns the dimensions (in meters) for this Entity.

open Float

Returns the accumulated scale of this Entity.

open Boolean
isHidden(includeParents: Boolean)

Returns the hidden status of this Entity.

open Unit

Remove all components from this Entity.

open Unit

Removes the given Component from this Entity.

open Unit
setAlpha(alpha: Float)

Sets the alpha transparency of the Entity and its children.

open Unit

Sets alternate text for this entity to be consumed by Accessibility systems.

open Unit
setHidden(hidden: Boolean)

Sets the local hidden state of this Entity.

open Unit
setParent(parent: Entity?)

Sets this Entity to be represented in the parent's coordinate space.

open Unit
setPose(pose: Pose)

Sets the pose for this Entity, relative to its parent.

open Unit
setScale(scale: Float)

Sets the scale of this entity relative to its parent.

open Unit
setSize(dimensions: Dimensions)

Sets the dimensions in pixels for the Entity.

Public functions

addBoundsChangedListener

Added in 1.0.0-alpha01
fun addBoundsChangedListener(listener: Consumer<Dimensions>): Unit

Adds the given Consumer as a listener to be invoked when this ActivitySpace's current boundary changes. Consumer#accept(Dimensions) will be invoked on the main thread.

Parameters
listener: Consumer<Dimensions>

The Consumer to be invoked when this ActivitySpace's current boundary changes.

addBoundsChangedListener

Added in 1.0.0-alpha01
fun addBoundsChangedListener(
    callbackExecutor: Executor,
    listener: Consumer<Dimensions>
): Unit

Adds the given Consumer as a listener to be invoked when this ActivitySpace's current boundary changes. Consumer#accept(Dimensions) will be invoked on the given executor.

Parameters
callbackExecutor: Executor

The executor on which to invoke the listener on.

listener: Consumer<Dimensions>

The Consumer to be invoked when this ActivitySpace's current boundary changes.

getBounds

Added in 1.0.0-alpha01
fun getBounds(): Dimensions

Retrieves a copy of the current bounds of this ActivitySpace.

Returns
Dimensions

Dimensions representing the current bounds of this ActivitySpace.

registerOnBoundsChangedListener

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
fun registerOnBoundsChangedListener(listener: OnBoundsChangeListener): Unit

Sets a callback to be invoked when the bounds of the ActivitySpace change. The callback will be dispatched on the UI thread.

Parameters
listener: OnBoundsChangeListener

A ((Dimensions) -> Unit) callback, where Dimensions are in meters.

removeBoundsChangedListener

Added in 1.0.0-alpha01
fun removeBoundsChangedListener(listener: Consumer<Dimensions>): Unit

Releases the given Consumer from receiving updates when the ActivitySpace's boundary changes.

Parameters
listener: Consumer<Dimensions>

The Consumer to be removed from receiving updates.

setOnSpaceUpdatedListener

Added in 1.0.0-alpha01
fun setOnSpaceUpdatedListener(
    listener: OnSpaceUpdatedListener?,
    executor: Executor? = null
): Unit

Registers a listener to be called when the underlying space has moved or changed.

Parameters
listener: OnSpaceUpdatedListener?

The listener to register if non-null, else stops listening if null.

executor: Executor? = null

The executor to run the listener on. Defaults to SceneCore executor if null.

unregisterOnBoundsChangedListener

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
fun unregisterOnBoundsChangedListener(): Unit

Clears the listener set by registerOnBoundsChangedListener.