可以使用以下代码来获取当前设备是否支持ARcore:
private boolean checkARCoreSupport(Activity activity) {
try {
// First we need to check for the existence of the ARCore service
PackageManager packageManager = activity.getPackageManager();
packageManager.getPackageInfo("com.google.ar.core", PackageManager.GET_SERVICES);
// Then we need to check if the device is compatible
ArCoreApk.Availability availability = ArCoreApk.getInstance().checkAvailability(activity);
return availability.isSupported();
} catch (PackageManager.NameNotFoundException e) {
// ARCore is not installed, return false
return false;
}
}
该方法使用PackageManager来检查设备上是否安装了ARCore服务,并使用ArCoreApk来检查设备是否兼容ARCore。如果返回值为true,则当前设备支持ARcore,否则不支持。