class Session


A session is the main entrypoint to features provided by ARCore for Jetpack XR. It manages the system's state and its lifecycle, and contains the state of objects tracked by ARCore for Jetpack XR.

This class owns a significant amount of native heap memory. The Session's lifecycle will be scoped to the Activity that owns it.

Summary

Public companion functions

SessionCreateResult
create(activity: Activity, coroutineContext: CoroutineContext)

Creates a new Session.

SessionCreateResult
create(
    activity: Activity,
    lifecycleOwner: LifecycleOwner,
    coroutineContext: CoroutineContext
)

Creates a new Session with a provided LifecycleOwner.

Public functions

SessionConfigureResult
configure(config: Config)

Sets or changes the configuration to use.

Public properties

Config

The current state of the runtime configuration.

StateFlow<CoreState>

A StateFlow of the current state.

Extension properties

Flowable<CoreState>

A Flowable of the current CoreState.

Scene

Gets the Scene associated with this Session.

Public companion functions

create

Added in 1.0.0-alpha05
fun create(
    activity: Activity,
    coroutineContext: CoroutineContext = EmptyCoroutineContext
): SessionCreateResult

Creates a new Session.

Parameters
activity: Activity

the Activity that provides the context for the session's resources and controls the session's runtime state based on the activity's lifecycle.

coroutineContext: CoroutineContext = EmptyCoroutineContext

the CoroutineContext that will be used to handle the session's coroutines.

Returns
SessionCreateResult

the result of the operation. Can be SessionCreateSuccess, which contains the newly created session, or another SessionCreateResult if a certain criteria was not met.

Throws
java.lang.SecurityException

if the Session is backed by Google Play Services for AR and android.Manifest.permission.CAMERA has not been granted to the calling application.

create

Added in 1.0.0-alpha05
fun create(
    activity: Activity,
    lifecycleOwner: LifecycleOwner,
    coroutineContext: CoroutineContext = EmptyCoroutineContext
): SessionCreateResult

Creates a new Session with a provided LifecycleOwner.

Only use this version of the constructor if you desire to have finer control over the session's lifecycle. The lifecycleOwner's lifecycle must still be bounded within the lifecycle of the provided activity. The session will be automatically destroyed if the activity's lifecycle becomes destroyed.

Parameters
activity: Activity

the Activity that provides the context for the session's resources.

lifecycleOwner: LifecycleOwner

the LifecycleOwner whose lifecycle controls the runtime state of the session.

coroutineContext: CoroutineContext = EmptyCoroutineContext

the CoroutineContext that will be used to handle the session's coroutines.

Returns
SessionCreateResult

the result of the operation. Can be SessionCreateSuccess, which contains the newly created session, or another SessionCreateResult if a certain criteria was not met.

Throws
java.lang.SecurityException

if the Session is backed by Google Play Services for AR and android.Manifest.permission.CAMERA has not been granted to the calling application.

Public functions

configure

Added in 1.0.0-alpha05
fun configure(config: Config): SessionConfigureResult

Sets or changes the configuration to use.

Returns
SessionConfigureResult

the result of the operation. This will be a SessionConfigureSuccess if the configuration was successful, or another SessionConfigureResult if a certain configuration criteria was not met.

Throws
kotlin.IllegalStateException

if the session has been destroyed.

java.lang.SecurityException

if the necessary permissions have not been granted to the calling application for the provided configuration.

Public properties

config

Added in 1.0.0-alpha05
val configConfig

The current state of the runtime configuration.

state

Added in 1.0.0-alpha05
val stateStateFlow<CoreState>

A StateFlow of the current state.

Extension properties

val Session.sceneScene

Gets the Scene associated with this Session.

The Scene is the primary interface for creating and managing spatial content. There is a single Scene instance for each Session.

See also
Scene