Skip to content

Commit 88e313c

Browse files
authored
Add information on accessing the underlying mobile runtime (#720)
1 parent 80154a1 commit 88e313c

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

gradle/libs.versions.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ androidx-xr-compose = "1.0.0-alpha08"
3434
androidx-xr-scenecore = "1.0.0-alpha08"
3535
androidxHiltNavigationCompose = "1.3.0"
3636
appcompat = "1.7.1"
37+
arcorePlayServices = "1.0.0-alpha08"
3738
coil = "2.7.0"
3839
# @keep
3940
compileSdk = "36"
@@ -47,6 +48,7 @@ datastorePreferencesRxjava2 = "1.1.7"
4748
datastorePreferencesRxjava3 = "1.1.7"
4849
firebase-bom = "34.4.0"
4950
glide = "1.0.0-beta08"
51+
google-ar-core = "1.51.0"
5052
google-maps = "19.2.0"
5153
gradle-versions = "0.53.0"
5254
guava = "33.5.0-jre"
@@ -104,6 +106,7 @@ android-identity-googleid = { module = "com.google.android.libraries.identity.go
104106
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity-compose" }
105107
androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref = "activityKtx" }
106108
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
109+
androidx-arcore-play-services = { module = "androidx.xr.arcore:arcore-play-services", version.ref = "arcorePlayServices" }
107110
androidx-compose-animation-graphics = { module = "androidx.compose.animation:animation-graphics", version.ref = "compose-latest" }
108111
androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "androidx-compose-bom" }
109112
androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose-latest" }
@@ -202,6 +205,7 @@ firebase-ai = { module = "com.google.firebase:firebase-ai" }
202205
firebase-bom = { module = "com.google.firebase:firebase-bom", version.ref = "firebase-bom" }
203206
glide-compose = { module = "com.github.bumptech.glide:compose", version.ref = "glide" }
204207
google-android-material = { module = "com.google.android.material:material", version.ref = "material" }
208+
google-ar-core = { module = "com.google.ar:core", version.ref = "google-ar-core" }
205209
google-protobuf-kotlin-lite = { group = "com.google.protobuf", name = "protobuf-kotlin-lite", version.ref = "protobuf" }
206210
googlemaps-compose = { module = "com.google.maps.android:maps-compose", version.ref = "maps-compose" }
207211
googlemaps-maps = { module = "com.google.android.gms:play-services-maps", version.ref = "google-maps" }

xr/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ android {
3232

3333
dependencies {
3434
implementation(libs.androidx.xr.arcore)
35+
implementation(libs.androidx.arcore.play.services)
36+
implementation(libs.google.ar.core)
3537
implementation(libs.androidx.xr.scenecore)
3638
implementation(libs.androidx.xr.compose)
3739

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.xr.arcore
18+
19+
import androidx.xr.arcore.playservices.ArCoreRuntime
20+
import androidx.xr.arcore.playservices.UnsupportedArCoreCompatApi
21+
import androidx.xr.runtime.Session
22+
23+
@OptIn(UnsupportedArCoreCompatApi::class)
24+
fun accessMobileRuntime(session: Session) {
25+
// [START androidxr_arcore_mobile_runtime]
26+
val arCoreRuntime = session.runtimes.firstNotNullOfOrNull { it as? ArCoreRuntime } ?: return
27+
val originalSession = arCoreRuntime.lifecycleManager.session()
28+
val originalFrame = arCoreRuntime.perceptionManager.lastFrame()
29+
// [END androidxr_arcore_mobile_runtime]
30+
}

0 commit comments

Comments
 (0)