This site has been permanently archived. The content on this site was last updated in 2019.
AndroidCompat
Stay organized with collections
Save and categorize content based on your preferences.
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
|
|
static
boolean
|
|
static
boolean
|
|
Inherited Methods
From class
java.lang.Object
boolean
|
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
Public Methods
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
true
if this succeeded, false
otherwise. 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
true
if this succeeded, false
otherwise. This can fail either because
the device does not support VR mode, or because Google VR Services is unavailable.
All rights reserved. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-09 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-09 UTC."],[[["\u003cp\u003e\u003ccode\u003eAndroidCompat\u003c/code\u003e is a utility class providing access to VR features across different Android versions.\u003c/p\u003e\n"],["\u003cp\u003eIt offers methods to manage sustained performance mode and enable/disable VR mode for Activities.\u003c/p\u003e\n"],["\u003cp\u003eFunctionality is experimental and may change in future releases.\u003c/p\u003e\n"],["\u003cp\u003eVR mode features depend on the device's compatibility and the availability of Google VR Services.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003esetVrModeEnabled\u003c/code\u003e will prompt the user to install/enable Google VR Services if not present on Daydream-ready devices while \u003ccode\u003etrySetVrModeEnabled\u003c/code\u003e will not.\u003c/p\u003e\n"]]],["The `AndroidCompat` class provides utility for VR features across Android versions. Key actions include setting sustained performance mode for an `Activity`'s `Window` and enabling VR mode for an `Activity`. `setSustainedPerformanceMode` toggles sustained performance. `setVrModeEnabled` and `trySetVrModeEnabled` activate VR mode, with the former prompting for Google VR Services installation if necessary. Both VR mode methods require Android N+ and might fail if the device or Google VR Services doesn't support VR.\n"],null,["# AndroidCompat\n\npublic final class **AndroidCompat** \nUtility class for using VR-related features that may not be available with all Android versions.\n\n**Warning:** The functionality is experimental and subject to change in\nfuture releases. \n\n### Public Methods\n\n|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static void | [setSustainedPerformanceMode](/vr/reference/android/com/google/vr/sdk/base/AndroidCompat#setSustainedPerformanceMode(android.app.Activity,%20boolean))([Activity](https://developer.android.com/reference/android/app/Activity) activity, boolean enabled) Sets the current android.view.Window to sustained performance mode, when available. |\n| static boolean | [setVrModeEnabled](/vr/reference/android/com/google/vr/sdk/base/AndroidCompat#setVrModeEnabled(android.app.Activity,%20boolean))([Activity](https://developer.android.com/reference/android/app/Activity) activity, boolean enabled) Sets the appropriate \"VR mode\" setting for an Activity. |\n| static boolean | [trySetVrModeEnabled](/vr/reference/android/com/google/vr/sdk/base/AndroidCompat#trySetVrModeEnabled(android.app.Activity,%20boolean))([Activity](https://developer.android.com/reference/android/app/Activity) activity, boolean enabled) Sets the appropriate \"VR mode\" setting for an Activity. |\n\n### Inherited Methods\n\nFrom class java.lang.Object \n\n|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------|\n| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object) arg0) |\n| final [Class](https://developer.android.com/reference/java/lang/Class)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](https://developer.android.com/reference/java/lang/String) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Methods\n--------------\n\n#### public static void\n**setSustainedPerformanceMode**\n([Activity](https://developer.android.com/reference/android/app/Activity) activity, boolean enabled)\n\nSets the current android.view.Window to sustained performance mode, when available. \n\n##### Parameters\n\n| activity | The current Activity. |\n| enabled | Whether to enable sustained performance mode. |\n|----------|-----------------------------------------------|\n\n#### public static boolean\n**setVrModeEnabled**\n([Activity](https://developer.android.com/reference/android/app/Activity) activity, boolean enabled)\n\nSets the appropriate \"VR mode\" setting for an Activity.\n\nThis should typically be called in Activity.onCreate for pure VR activities, and will only\nhave an effect on Android N+ devices that support the \"android.software.vr.mode\" feature.\n\nOn Daydream-ready devices, if Google VR Services is not present and enabled, this will\nprompt the user to install or enable Google VR Services before continuing. If the user\ncontinues without Google VR Services present and enabled, the Android OS will not enter VR\nmode, and some functionality may not be available (e.g. the controller). \n\n##### Parameters\n\n| activity | The Activity for which to set VR mode. |\n| enabled | Whether to enable VR mode. |\n|----------|----------------------------------------|\n\n##### Returns\n\n- `true` if this succeeded, `false` otherwise. This can fail either because the device does not support VR mode, or because Google VR Services is unavailable. \n\n#### public static boolean\n**trySetVrModeEnabled**\n([Activity](https://developer.android.com/reference/android/app/Activity) activity, boolean enabled)\n\nSets the appropriate \"VR mode\" setting for an Activity.\n\nThis should typically be called in Activity.onCreate for pure VR activities, and will only\nhave an effect on Android N+ devices that support the \"android.software.vr.mode\" feature.\n\nOn N+ devices, if Google VR Services is not present and enabled, this will do nothing. If\nGoogle VR Services is not present and enabled, the Android OS will not enter VR mode, and some\nfunctionality may not be available (e.g. the controller). \n\n##### Parameters\n\n| activity | The Activity for which to set VR mode. |\n| enabled | Whether to enable VR mode. |\n|----------|----------------------------------------|\n\n##### Returns\n\n- `true` if this succeeded, `false` otherwise. This can fail either because the device does not support VR mode, or because Google VR Services is unavailable."]]