Your VR application's AndroidManifest.xml
file contains several attributes
that affect how it works in the Daydream and Cardboard platforms.
VR Application attributes
There are a specific set of feature, permission and Android SDK requirements for Cardboard and Daydream apps. These should be specified as top-level entries in the application manifest:
<manifest ...>
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="24"/>
...
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-feature android:name="android.software.vr.mode" android:required="false"/>
<uses-feature android:name="android.hardware.vr.high_performance" android:required="false"/>
...
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
...
</manifest>
The minimum Android SDK version supported by the Google VR SDK is API 19, as
specified by <uses-sdk android:minSdkVersion="19"/>
. Specifying the target SDK
version is optional for Cardboard apps, but Daydream apps should target API 24
or later.
OpenGL ES 2.0 is required to properly render VR content, as noted with
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
.
Android N introduces two new features: "android.software.vr.mode"
and
"android.hardware.vr.high_performance"
. The former indicates use of Android's
VR mode, while the latter indicates use of Daydream-ready device features. These
should be marked as required solely for Daydream-only apps.
The android.permission.READ_EXTERNAL_STORAGE
permission is required by the
Google VR SDK to pair the user's phone to their VR viewer, but is only strictly
necessary when Google VR Services is unavailable. Google VR Services will be
preinstalled on all Daydream-ready devices.
VR Activity attributes
To make your Activity compatible with Daydream, you must declare some attributes in the manifest file:
<activity
android:name=".MyActivity"
android:screenOrientation="landscape"
android:enableVrMode="@string/gvr_vr_mode_component"
android:theme="@style/VrActivityTheme"
android:resizeableActivity="false"
android:configChanges="density|keyboardHidden|navigation|orientation|screenSize|uiMode"
...>
The android:enableVrMode
attribute enables Android VR Mode, a feature
introduced in Android 7.0 (Nougat)
to allow high-performance mobile VR applications.
This attribute indicates to the system that it should enable VR mode
automatically when your Activity launches.
The android:theme
attribute above ensures that your Activity will look and
behave correctly during VR transitions, and setting android:resizeableActivity
to false
indicates that your Activity can't be resized to share the screen
with another Activity. The screen should always be in landscape mode, controlled
by setting the android:screenOrientation
attribute to landscape
.
The android:configChanges
attribute is necessary to avoid teardown and
recreation of the Activity when certain Android configuration changes occur. Such
teardown can be disruptive to the Daydream experience, particularly during
transitions. See the Android Activity
documentation for a more complete description of each entry.
Platform compatibility
Each of your Activities must declare which VR platforms it supports
(Daydream and/or Cardboard). You can do this by adding the DAYDREAM
and/or
CARDBOARD
categories in the Activity's intent-filters
section. For example,
if your Activity only suppors Daydream but not Cardboard, you would declare it
as follows:
<!-- Example of a Daydream-only Activity -->
<activity ... >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- This marks the Activity as a Daydream Activity and allows it
to be launched from the Daydream Home. -->
<category android:name="com.google.intent.category.DAYDREAM" />
<!-- This allows this Activity to be launched from the traditional
Android 2D launcher as well. Remove it if you do not want
this Activity to be launched directly from the 2D launcher. -->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
If your Activity supports both Daydream and the Cardboard platforms, you
should also declare the CARDBOARD
category:
<!-- Example of a Daydream/Cardboard Activity -->
<activity ... >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- This marks the Activity as a Daydream Activity and allows it
to be launched from the Daydream Home. -->
<category android:name="com.google.intent.category.DAYDREAM" />
<!-- This marks the Activity as a Cardboard Activity and allows it
to be launched from the Cardboard app. -->
<category android:name="com.google.intent.category.CARDBOARD" />
<!-- This allows this Activity to be launched from the traditional
Android 2D launcher as well. Remove it if you do not want
this Activity to be launched directly from the 2D launcher. -->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Lastly, if your Activity only supports Cardboard, you should declare the
CARDBOARD
category but not the DAYDREAM
category:
<!-- Example of a Cardboard-only Activity -->
<activity ... >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- This marks the Activity as a Cardboard Activity and allows it
to be launched from the Cardboard app. -->
<category android:name="com.google.intent.category.CARDBOARD" />
<!-- This allows this Activity to be launched from the traditional
Android 2D launcher as well. Remove it if you do not want
this Activity to be launched directly from the 2D launcher. -->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
VR icon
If your Activity is only meant to be launched from the 2D home screen, a standard icon is sufficient. However, if the Activity supports Daydream, it should include a VR icon. If it does not have a VR icon, it will not show up in the Daydream app launcher.