【问题标题】:Know if a given device is in the list of supported devices for AR了解给定设备是否在 AR 支持的设备列表中
【发布时间】:2020-01-22 13:14:57
【问题描述】:
有什么方法可以知道给定设备是否支持 AR?
我现在正在这样做:
ArCoreApk.Availability availability = ArCoreApk.getInstance().checkAvailability(this);
if(availability.isSupported()){
Log.i("David", "Supported");
}else{
Log.i("David", "Not supported");
}
AFAIK,这仅检查 ArcCore 库是否安装在设备中,而不是设备是否位于受支持设备的 list 中。我必须一一检查该列表吗?
【问题讨论】:
标签:
android
augmented-reality
android-augmented-reality
【解决方案1】:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
maybeEnableArButton();
}
void maybeEnableArButton() {
ArCoreApk.Availability availability = ArCoreApk.getInstance().checkAvailability(this);
if (availability.isTransient()) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
maybeEnableArButton();
}
}, 200);
}
if (availability.isSupported()) {
mArButton.setVisibility(View.VISIBLE);
mArButton.setEnabled(true);
// indicator on the button.
} else { // Unsupported or unknown.
mArButton.setVisibility(View.INVISIBLE);
mArButton.setEnabled(false);
}
}
通过这个,您可以检查设备是否支持 ARCore。如果没有安装 ARCore,那么您可以使用 ArCoreApk.requestInstall() 检查,ArCore 安装将无法仅在受支持的设备上进行。