Reputation: 613
I'm using sceneform to create an AR app in Android Studio. Everything works as expected on supported devices. However on unsupported devices i want the user of the app to alternatively view the 3d object / model without the augmented reality feature like in Google expeditions Expeditions App. How can i achieve this?
Upvotes: 0
Views: 267
Reputation: 10729
The solution to this might not be simple and may require two side-by-side applications. I'll give a high level view of what I think. It'd be good to see what you have right now, post a git repo link you have. But I assume that somewhere along the line you have an AR view Fragment in your code. That fragment contains some compatibility check, like so:
@Override
public void onAttach(Context context) {
super.onAttach(context);
// Check for Sceneform being supported on this device. This check will be integrated into
// Sceneform eventually.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
Log.e(TAG, "Sceneform requires Android N or later");
Snackbar.make(getActivity().findViewById(android.R.id.content),
"Sceneform requires Android N or later",
Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
String openGlVersionString =
((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE))
.getDeviceConfigurationInfo()
.getGlEsVersion();
if (Double.parseDouble(openGlVersionString) < MIN_OPENGL_VERSION) {
Log.e(TAG, "Sceneform requires OpenGL ES 3.0 or later");
Snackbar.make(getActivity().findViewById(android.R.id.content),
"Sceneform requires OpenGL ES 3.0 or later",
Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
}
Here you can revert to a non AR solution. The problem is that normally this point is too late to revert back to a compatible view for unsupported devices. If you look at your AndroidManifest.xml
, you see two entries related to AR there:
<uses-feature android:name="android.hardware.camera.ar" android:required="true"/>
and
<meta-data android:name="com.google.ar.core" android:value="required" />
These two entries are picked up by the Google Play Store system, and it automatically won't offer the app for devices which are not compatible. There are two ways here you can gravitate towards:
Disclaimer: these are concepts and I never tried to spawn an AR Core instant app.
Upvotes: 0