GvrActivity

public class GvrActivity

Base activity that provides easy integration with GVR headsets.

Exposes events to interact with GVR headsets and handles many of the details commonly required when creating an Activity for VR rendering.

This activity keeps the screen ON as long as it detects that the phone is moving. This way the screen saver won't kick in while users are experiencing VR content. If no phone movement is detected for ~30 seconds, the regular screen wakelock policy is restored.

Inherited Constants

Public Constructors

Public Methods

GvrView
void
void
void
setGvrView(GvrView gvrView)
void
setGvrView(GvrView gvrView, boolean enableVrModeFallbacks)

Inherited Methods

Public Constructors

public GvrActivity ()

Public Methods

public GvrView getGvrView ()

Returns the GvrView associated with this activity.

Returns
  • The GvrView object associated with this activity. Can be null.

public void onBackPressed ()

Invokes the currently configured "close" behavior, in addition to the default Activity.onBackPressed() behavior.

For Cardboard apps, this will be identical to Activity.onBackPressed(). For Daydream apps, this will finish the Activity and restore the 2D launcher.

public void onCardboardTrigger ()

Override to detect when the Cardboard trigger was pulled and released.

Provides click-like events when the display is inside a Cardboard viewer.

public void setGvrView (GvrView gvrView)

Associates a GVR view with this activity.

This method does not set or change the content view, but associates the activity with a GvrView and ensures it receives any required activity lifecycle notifications.

This is automatically done if setContentView is used to directly set a GvrView object, and should be called if the GvrView is set in any other way (e.g. from a layout resource).

On Android N+, setting a valid GvrView will also enable VR mode while the activity is visible. If Google VR Services is not present or enabled, this will prompt the user to install or enable Google VR Services before continuing.

Parameters
gvrView The GvrView to associate with. Can be null.

public void setGvrView (GvrView gvrView, boolean enableVrModeFallbacks)

Associates a GVR view with this activity.

This method does not set or change the content view, but associates the activity with a GvrView and ensures it receives any required activity lifecycle notifications.

This is automatically done if setContentView is used to directly set a GvrView object, and should be called if the GvrView is set in any other way (e.g. from a layout resource).

On Android N+, setting a valid GvrView will also enable VR mode while the activity is visible. If Google VR Services is not present and enabled, this will prompt the user to install or enable Google VR Services before continuing if enableVrModeFallbacks has been set to true. 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
gvrView The GvrView to associate with. Can be null.
enableVrModeFallbacks true to show the user a prompt to handle the case where Google VR Services is not present and enabled.