ActivityPanelEntity


public final class ActivityPanelEntity extends PanelEntity


ActivityPanelEntity creates a spatial panel for embedding an Activity in Android XR. Users can either use an intent to launch an activity in the given panel or provide an instance of activity to move into this panel. Calling dispose() on this entity will destroy the underlying activity.

Summary

Public methods

static final @NonNull ActivityPanelEntity
create(
    @NonNull Session session,
    @NonNull Rect windowBoundsPx,
    @NonNull String name,
    @NonNull Pose pose
)

Public factory function for a spatial ActivityPanelEntity.

final void
launchActivity(@NonNull Intent intent, Bundle bundle)

Launches an activity in the given panel.

final void

Moves the given activity into this panel.

Inherited methods

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

Returns the activity space pose for this ActivityPose.

abstract @NonNull ListenableFuture<@NonNull HitTestResult>
hitTestAsync(@NonNull Vector3 origin, @NonNull Vector3 direction)

Creates a hit test from the specified origin in the specified direction into the scene.

abstract @NonNull ListenableFuture<@NonNull HitTestResult>
hitTestAsync(
    @NonNull Vector3 origin,
    @NonNull Vector3 direction,
    @ActivityPose.HitTestFilterValue int hitTestFilter
)

Creates a hit test from the specified origin in the specified direction into the scene.

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
getAlpha(int relativeTo)

Returns the alpha transparency set for this Entity, relative to given space.

@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
getPose(int relativeTo)

Returns the pose for this entity, relative to the provided space.

float
getScale(int relativeTo)

Returns the scale of this entity, relative to given space.

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, int relativeTo)

Sets the alpha transparency of the Entity relative to given space.

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
setPose(@NonNull Pose pose, int relativeTo)

Sets the pose for this Entity.

void
setScale(float scale, int relativeTo)

Sets the scale of this entity relative to given space.

From androidx.xr.scenecore.BasePanelEntity
final float

Gets the corner radius of this PanelEntity in meters.

final @NonNull Vector3

This method is deprecated. This api will be removed in a future release.

final @NonNull Dimensions

Returns the dimensions in local space, in unscaled meters for this panel entity.

final @NonNull PixelDimensions

Returns the dimensions in Pixels for this panel entity.

final void
setCornerRadius(float radius)

Sets the corner radius of the PanelEntity.

final void
setSize(@NonNull Dimensions dimensions)

Sets the size in meters for the surface on which the View is laid out.

final void

Sets the size in pixels for the surface on which the view is laid out.

From androidx.xr.scenecore.Entity
float

Returns the alpha transparency set for 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.

void
setAlpha(float alpha)

Sets the alpha transparency of the Entity and its children.

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.

From androidx.xr.scenecore.PanelEntity
final boolean

Public methods

create

Added in 1.0.0-alpha04
public static final @NonNull ActivityPanelEntity create(
    @NonNull Session session,
    @NonNull Rect windowBoundsPx,
    @NonNull String name,
    @NonNull Pose pose
)

Public factory function for a spatial ActivityPanelEntity.

Parameters
@NonNull Session session

Session to create the ActivityPanelEntity in.

@NonNull Rect windowBoundsPx

Bounds for the panel window in pixels.

@NonNull String name

Name of the panel.

@NonNull Pose pose

Pose of this entity relative to its parent, default value is Identity.

Returns
@NonNull ActivityPanelEntity

an ActivityPanelEntity instance.

launchActivity

Added in 1.0.0-alpha04
public final void launchActivity(@NonNull Intent intent, Bundle bundle)

Launches an activity in the given panel. Subsequent calls to this method will replace the already existing activity in the panel with the new one. If the intent fails to launch the activity, the panel will not be visible. Note this will not update the dimensions of the surface underlying the panel. The Activity will be letterboxed as required to fit the size of the panel. The underlying surface can be resized by calling setSizeInPixels().

Parameters
@NonNull Intent intent

Intent to launch the activity.

Bundle bundle

Bundle to pass to the activity, can be null.

moveActivity

Added in 1.0.0-alpha04
public final void moveActivity(@NonNull Activity activity)

Moves the given activity into this panel. Note this will not update the dimensions of the surface underlying the panel. The Activity will be letterboxed as required to fit the size of the panel. The underlying surface can be resized by calling setSizeInPixels().

Parameters
@NonNull Activity activity

Activity to move into this panel.