ActivitySpace


public final class ActivitySpace extends 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 methods

final void

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

final void
addBoundsChangedListener(
    @NonNull Executor callbackExecutor,
    @NonNull Consumer<@NonNull Dimensions> listener
)

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

final @NonNull Dimensions

Retrieves a copy of the current bounds of this ActivitySpace.

final void

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

final void

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

final void
setOnSpaceUpdatedListener(
    OnSpaceUpdatedListener listener,
    Executor executor
)

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

final void

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

Inherited methods

From androidx.xr.scenecore.ActivityPose
abstract @NonNull Pose

Returns the activity space pose for this ActivityPose.

abstract @NonNull Pose

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

From androidx.xr.scenecore.BaseEntity
void

Sets an Entity to be represented in this coordinate space.

boolean

Adds a Component to this Entity.

void

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

float

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

float

Returns the alpha transparency set for this Entity.

@NonNull List<@NonNull Component>

Retrieves all components attached to this Entity.

@NonNull List<@NonNull T>

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

Entity

Returns the parent of this Entity.

@NonNull Pose

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

float

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

@NonNull Dimensions

Returns the dimensions (in meters) for this Entity.

float

Returns the accumulated scale of this Entity.

boolean
isHidden(boolean includeParents)

Returns the hidden status of this Entity.

void

Remove all components from this Entity.

void

Removes the given Component from this Entity.

void
setAlpha(float alpha)

Sets the alpha transparency of the Entity and its children.

void

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

void
setHidden(boolean hidden)

Sets the local hidden state of this Entity.

void
setParent(Entity parent)

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

void

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

void
setScale(float scale)

Sets the scale of this entity relative to its parent.

void
setSize(@NonNull Dimensions dimensions)

Sets the dimensions in pixels for the Entity.

Public methods

addBoundsChangedListener

Added in 1.0.0-alpha01
public final void addBoundsChangedListener(@NonNull Consumer<@NonNull Dimensions> listener)

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
@NonNull Consumer<@NonNull Dimensions> listener

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

addBoundsChangedListener

Added in 1.0.0-alpha01
public final void addBoundsChangedListener(
    @NonNull Executor callbackExecutor,
    @NonNull Consumer<@NonNull Dimensions> listener
)

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
@NonNull Executor callbackExecutor

The executor on which to invoke the listener on.

@NonNull Consumer<@NonNull Dimensions> listener

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

getBounds

Added in 1.0.0-alpha01
public final @NonNull Dimensions getBounds()

Retrieves a copy of the current bounds of this ActivitySpace.

Returns
@NonNull Dimensions

Dimensions representing the current bounds of this ActivitySpace.

registerOnBoundsChangedListener

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public final void registerOnBoundsChangedListener(
    @NonNull OnBoundsChangeListener listener
)

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

Parameters
@NonNull OnBoundsChangeListener listener

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

removeBoundsChangedListener

Added in 1.0.0-alpha01
public final void removeBoundsChangedListener(
    @NonNull Consumer<@NonNull Dimensions> listener
)

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

Parameters
@NonNull Consumer<@NonNull Dimensions> listener

The Consumer to be removed from receiving updates.

setOnSpaceUpdatedListener

Added in 1.0.0-alpha01
public final void setOnSpaceUpdatedListener(
    OnSpaceUpdatedListener listener,
    Executor executor
)

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

Parameters
OnSpaceUpdatedListener listener

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

Executor executor

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
public final void unregisterOnBoundsChangedListener()

Clears the listener set by registerOnBoundsChangedListener.