Session는 애플리케이션의 공간화된 기능에 대한 기본 인터페이스를 제공합니다. 각 공간화된 Activity는 Session 인스턴스를 만들고 유지해야 합니다. 일단 생성되면 애플리케이션은 Session 인터페이스를 사용하여 패널이나 3D 모델과 같은 공간화된 콘텐츠 항목을 만들고 공간 환경을 설정, 사용자 위치를 식별, 실제 세계에 콘텐츠를 고정할 수 있습니다.
XR용 Jetpack Compose에서 세션에 액세스
XR용 Jetpack Compose를 사용하면 세션이 자동으로 생성되며 LocalSession.current를 사용하여 액세스할 수 있습니다. 아래 예를 참고하세요.
세션 만들기는 Android XR 기기에서만 지원됩니다. 호환되지 않는 기기에서 세션을 만들려고 하면 실패합니다. 세션을 만들려면 다음 예와 같이 활동을 create() 메서드에 전달합니다.
when(valresult=Session.create(this)){isSessionCreateSuccess->{valxrSession=result.session// ...}else->
TODO(/* A different unhandled exception was thrown. */)}
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-08-23(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-23(UTC)"],[],[],null,["# Session\n\nThe [`Session`](/reference/kotlin/androidx/xr/runtime/Session) provides the primary interface to spatialized functionality\nfor the application. Each spatialized Activity must create and hold an instance\nof `Session`. Once created, the application can use the `Session` interfaces to\ncreate spatialized content entities such as panels or 3d models, as well as [set\na spatial environment](/develop/xr/jetpack-xr-sdk/add-environments), [identify user position](/reference/kotlin/androidx/xr/scenecore/SpatialUser), and [anchor content](/develop/xr/jetpack-xr-sdk/work-with-entities)\nto the real world.\n| **Caution:** Due to a [known issue](/jetpack/androidx/releases/xr-scenecore#1.0.0-alpha04) that ties the session to the Activity lifecycle, the session can become invalid in various situations that automatically recreate the activity. These include, but are not limited to resizing a main panel, connecting peripherals, and changing between light and dark theme. If you run into session invalidation issues, you may need to make your main panel non-resizable, use a dynamic panel entity, disable activity recreation for [specific config changes](/guide/topics/resources/runtime-changes#restrict-activity), or disable light or dark theme changes.\n\nAccess Session from Jetpack Compose for XR\n------------------------------------------\n\nWhen using Jetpack Compose for XR, the session is created for you and can be\naccessed using [`LocalSession.current`](/reference/kotlin/androidx/xr/compose/platform/package-summary#LocalSession()). See the following example:\n\n\n```kotlin\n@Composable\nfun ComposableUsingSession() {\n val session = LocalSession.current\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/xr/src/main/java/com/example/xr/runtime/Session.kt#L26-L29\n```\n\n\u003cbr /\u003e\n\nAccess Session from Jetpack SceneCore\n-------------------------------------\n\nIf you are creating spatialized entities from the SceneCore library, you'll need\nto create the session.\n\nCreating a session is only supported on an Android XR device. Attempting to\ncreate a session on an incompatible device will result in a failed result. To\ncreate a session, pass an activity to the [`create()`](/reference/kotlin/androidx/xr/runtime/Session#create(android.app.Activity,kotlin.coroutines.CoroutineContext)) method, as shown in\nthe following example.\n\n\n```kotlin\nwhen (val result = Session.create(this)) {\n is SessionCreateSuccess -\u003e {\n val xrSession = result.session\n // ...\n }\n else -\u003e\n TODO(/* A different unhandled exception was thrown. */)\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/xr/src/main/java/com/example/xr/runtime/Session.kt#L34-L41\n```\n\n\u003cbr /\u003e\n\n| **Note:** Some features, such as [hand tracking](/develop/xr/jetpack-xr-sdk/arcore/hands) and [plane tracking](/develop/xr/jetpack-xr-sdk/arcore/planes), require additional runtime permissions in order for session configuration to succeed.\n\nWhen a session's activity is destroyed, all spatial UI and 3D content associated\nwith that session is destroyed and the session is no longer valid.\n\nSee also\n--------\n\n- [Check for spatial capabilities](/develop/xr/jetpack-xr-sdk/check-spatial-capabilities)\n- [Transition between HSM and FSM](/develop/xr/jetpack-xr-sdk/transition-home-space-to-full-space)\n- [Add spatial environments to your app](/develop/xr/jetpack-xr-sdk/add-environments)\n- [Add 3D models to your app](/develop/xr/jetpack-xr-sdk/add-3d-models)"]]