ActivityPanelEntity


class ActivityPanelEntity : 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. In order to launch and embed an activity, SpatialCapability.EMBED_ACTIVITY capability is required. When this Entity is destroyed it will destroy the underlying Activity.

Summary

Public companion functions

ActivityPanelEntity
create(
    session: Session,
    pixelDimensions: IntSize2d,
    name: String,
    pose: Pose,
    parent: Entity?
)

Public factory function for a spatial ActivityPanelEntity.

Public functions

Unit

Starts an Activity in the given panel.

Unit

Transfers the given Activity into this panel.

Inherited functions

From androidx.xr.scenecore.BaseScenePose
open suspend HitTestResult?
hitTest(origin: Vector3, direction: Vector3)

Perform a hit test from the specified origin in the specified direction into the Scene.

open suspend HitTestResult?
hitTest(origin: Vector3, direction: Vector3, hitTestFilter: Int)

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

open Vector3
transformDirectionTo(direction: Vector3, destination: ScenePose)

Transforms a direction from this ScenePose's local space to the destination ScenePose's local space.

open Pose
transformPoseTo(pose: Pose, destination: ScenePose)

Returns a Pose relative to this ScenePose, transformed into a Pose relative to the destination.

open Vector3
transformPositionTo(position: Vector3, destination: ScenePose)

Transforms a position from this ScenePose's local space to the destination ScenePose's local space.

open Vector3
transformVectorTo(vector: Vector3, destination: ScenePose)

Transforms a vector from this ScenePose's local space to the destination ScenePose's local space.

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

Sets an Entity to be a child of this Entity in the scene graph.

Boolean
addComponent(component: Component)

Adds a Component to this Entity.

@FloatRange(from = 0.0, to = 1.0) Float
getAlpha(relativeTo: Space)

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

List<Component>

Retrieves all components attached to this Entity.

List<T>

Retrieves all Components of the given type T and its subtypes attached to this Entity.

open Pose
getPose(relativeTo: Space)

Returns the Pose for this Entity, relative to the provided Space.

open @FloatRange(from = 0.0) Float
getScale(relativeTo: Space)

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

Boolean
isEnabled(includeParents: Boolean)

Returns the enabled status of this Entity.

Unit

Remove all components from this Entity.

Unit

Removes the given Component from this Entity.

Unit
setAlpha(alpha: @FloatRange(from = 0.0, to = 1.0) Float)

Sets the alpha transparency of the Entity relative to the parent Space.

Unit
setEnabled(enabled: Boolean)

Sets the local enabled state of this Entity.

open Unit
setPose(pose: Pose, relativeTo: Space)

Sets the Pose for this Entity.

open Unit
setScale(scale: @FloatRange(from = 0.0) Float, relativeTo: Space)

Sets the scale of this Entity relative to the given Space.

From androidx.xr.scenecore.PanelEntity
PerceivedResolutionResult

Gets the perceived resolution of this Entity in the provided RenderViewpoint.

Vector3

Gets the 3D position of a 2D normalized extent coordinate within the entity's local space.

Vector3

Gets the 3D position of a 2D pixel coordinate within the entity's local space.

Inherited properties

From androidx.xr.scenecore.BaseScenePose
open Pose

The current Pose relative to the activity space root.

From androidx.xr.scenecore.Entity
List<Entity>

Provides the list of all children of this entity.

CharSequence

Alternate text for this Entity to be consumed by Accessibility systems.

Entity?

The parent of this Entity, from which this Entity will inherit most of its properties.

From androidx.xr.scenecore.PanelEntity
Float

The corner radius of the PanelEntity, in meters.

Boolean

True if this panel is the MainPanelEntity, false otherwise.

FloatSize2d

The dimensions of this PanelEntity in local space, in units relative to the scale of this Entity's parent.

IntSize2d

The dimensions of this PanelEntity, in pixels, which is the resolution of the underlying surface.

Public companion functions

create

Added in 1.0.0-alpha16
fun create(
    session: Session,
    pixelDimensions: IntSize2d,
    name: String,
    pose: Pose = Pose.Identity,
    parent: Entity? = null
): ActivityPanelEntity

Public factory function for a spatial ActivityPanelEntity.

Parameters
session: Session

XR Session to create the ActivityPanelEntity.

pixelDimensions: IntSize2d

Bounds for the panel surface in pixels.

name: String

Name of the panel.

pose: Pose = Pose.Identity

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

parent: Entity? = null

Parent entity. Defaults to null. If null, the entity is created but not attached to the scene graph, meaning it will be invisible. If a parent entity (e.g., ActivitySpace or any other Entity already present in the scene) is assigned later, the entity will become visible (provided it is enabled). This allows for Entity pre-configuration before making it visible.

Returns
ActivityPanelEntity

an ActivityPanelEntity instance.

Public functions

startActivity

Added in 1.0.0-alpha16
fun startActivity(intent: Intent): Unit

Starts an Activity in the given panel. Subsequent calls to this method will replace the already existing Activity in the panel with the new one. The panel will not be visible until an Activity is successfully launched. This will fail if the Scene does not have the SpatialCapability.EMBED_ACTIVITY capability. This method will not provide any information about when the Activity successfully launches.

Parameters
intent: Intent

Intent to launch the activity.

transferActivity

Added in 1.0.0-alpha16
fun transferActivity(activity: Activity): Unit

Transfers the given Activity into this panel. This will fail if the application does not have the SpatialCapability.EMBED_ACTIVITY capability.

Parameters
activity: Activity

Activity to move into this panel.