Page Summary
-
AndroidCompatis a utility class providing access to VR features across different Android versions. -
It offers methods to manage sustained performance mode and enable/disable VR mode for Activities.
-
Functionality is experimental and may change in future releases.
-
VR mode features depend on the device's compatibility and the availability of Google VR Services.
-
setVrModeEnabledwill prompt the user to install/enable Google VR Services if not present on Daydream-ready devices whiletrySetVrModeEnabledwill not.
Utility class for using VR-related features that may not be available with all Android versions.
Warning: The functionality is experimental and subject to change in future releases.
Public Methods
| static void |
setSustainedPerformanceMode(Activity activity, boolean enabled)
Sets the current android.view.Window to sustained performance mode, when available.
|
| static boolean |
setVrModeEnabled(Activity activity, boolean enabled)
Sets the appropriate "VR mode" setting for an Activity.
|
| static boolean |
trySetVrModeEnabled(Activity activity, boolean enabled)
Sets the appropriate "VR mode" setting for an Activity.
|
Inherited Methods
Public Methods
public static void setSustainedPerformanceMode (Activity activity, boolean enabled)
Sets the current android.view.Window to sustained performance mode, when available.
Parameters
| activity | The current Activity. |
|---|---|
| enabled | Whether to enable sustained performance mode. |
public static boolean setVrModeEnabled (Activity activity, boolean enabled)
Sets the appropriate "VR mode" setting for an Activity.
This should typically be called in Activity.onCreate for pure VR activities, and will only have an effect on Android N+ devices that support the "android.software.vr.mode" feature.
On Daydream-ready devices, if Google VR Services is not present and enabled, this will prompt the user to install or enable Google VR Services before continuing. If the user continues without Google VR Services present and enabled, the Android OS will not enter VR mode, and some functionality may not be available (e.g. the controller).
Parameters
| activity | The Activity for which to set VR mode. |
|---|---|
| enabled | Whether to enable VR mode. |
Returns
trueif this succeeded,falseotherwise. This can fail either because the device does not support VR mode, or because Google VR Services is unavailable.
public static boolean trySetVrModeEnabled (Activity activity, boolean enabled)
Sets the appropriate "VR mode" setting for an Activity.
This should typically be called in Activity.onCreate for pure VR activities, and will only have an effect on Android N+ devices that support the "android.software.vr.mode" feature.
On N+ devices, if Google VR Services is not present and enabled, this will do nothing. If Google VR Services is not present and enabled, the Android OS will not enter VR mode, and some functionality may not be available (e.g. the controller).
Parameters
| activity | The Activity for which to set VR mode. |
|---|---|
| enabled | Whether to enable VR mode. |
Returns
trueif this succeeded,falseotherwise. This can fail either because the device does not support VR mode, or because Google VR Services is unavailable.