android - ArCoreApk 检查可用性不适用于 api 30
问题描述
ArCoreApk 检查可用性在 API 级别 29 及以下返回 true,但在 30 上返回 false。有什么想法吗?
fun checkArCoreAvailability(context: Context) {
var message: String? = null
var isArCoreInstalled = false
try {
when (ArCoreApk.getInstance().checkAvailability(context)) {
ArCoreApk.Availability.UNKNOWN_ERROR -> {
message = "This device does not support AR, starting normal session"
}
ArCoreApk.Availability.UNKNOWN_CHECKING -> {
message = "This device does not support AR, starting normal session"
Handler().postDelayed({
checkArCoreAvailability(context)
}, 250)
}
ArCoreApk.Availability.UNKNOWN_TIMED_OUT -> {
message = "This device does not support AR, starting normal session"
}
ArCoreApk.Availability.UNSUPPORTED_DEVICE_NOT_CAPABLE -> {
message = "This device does not support AR, starting normal session"
}
ArCoreApk.Availability.SUPPORTED_NOT_INSTALLED -> {
message = "Please install ArCore to use pinned annotations"
}
ArCoreApk.Availability.SUPPORTED_APK_TOO_OLD -> {
message = "Please update ArCore to use pinned annotations"
}
ArCoreApk.Availability.SUPPORTED_INSTALLED -> {
isArCoreInstalled = true
message = "Starting AR Session"
}
null -> {
message = "This device does not support AR, starting normal session"
}
}
} catch (e: UnavailableArcoreNotInstalledException) {
message = "Please install ARCore to use pinned annotations"
} catch (e: UnavailableUserDeclinedInstallationException) {
message = "Please install ARCore to use pinned annotations"
} catch (e: UnavailableApkTooOldException) {
message = "Please update ARCore to use pinned annotations"
} catch (e: UnavailableSdkTooOldException) {
message = "Please update this app"
} catch (e: java.lang.Exception) {
message = "This device does not support AR, starting normal session"
}
Toast.makeText(context, message, Toast.LENGTH_LONG).show()
}
解决方案
尝试将适当的查询项添加到您的清单中:
<manifest>
<queries>
<package android:name="com.google.ar.core" />
</queries>
</manifest>
推荐阅读
- elasticsearch - Elasticsearch 动态分析器和同义词
- javascript - 当我将我的快速代码从路由文件移动到控制器文件时,api 不起作用。从邮递员那里点击 api 会导致一个无休止的请求
- javascript - 如何删除嵌套在两个数组中的对象?
- flutter - 如何在 Flutter 中获取异步值
- python - 如何将具有重复键的 JSON 文件导入数据框?
- javascript - 如何在 PhaserJS 中添加补间以使对象远离停止的位置?
- html - 如何删除包含 html 和 css 中的单选按钮的字段集周围的边框?
- c - sizeof 是否返回分配的内存量?
- c# - C# Specflow+ 如何在 .netcore 中为 TestRail API 创建线程之前一次性运行一些代码
- python - 带有 to 类对象的 YAML 配置文件