Skip to content

Most visited

Recently visited

navigation

VrListenerService

public abstract class VrListenerService
extends Service

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.service.vr.VrListenerService


A service that is bound from the system while running in virtual reality (VR) mode.

To extend this class, you must declare the service in your manifest file with the BIND_VR_LISTENER_SERVICE permission and include an intent filter with the SERVICE_INTERFACE action. For example:

 <service android:name=".VrListener"
          android:label="@string/service_name"
          android:permission="android.permission.BIND_VR_LISTENER_SERVICE">
     <intent-filter>
         <action android:name="android.service.vr.VrListenerService" />
     </intent-filter>
 </service>
 

This service is bound when the system enters VR mode and is unbound when the system leaves VR mode.

The system will enter VR mode when an application that has previously called setVrModeEnabled(boolean, ComponentName) gains user focus. The system will only start this service if the VR application has specifically targeted this service by specifying its ComponentName in the call to setVrModeEnabled(boolean, ComponentName) and if this service is installed and enabled in the current user's settings.

See also:

Summary

Constants

String SERVICE_INTERFACE

The Intent that must be declared as handled by the service.

Inherited constants

From class android.app.Service
From class android.content.Context
From interface android.content.ComponentCallbacks2

Public constructors

VrListenerService()

Public methods

static final boolean isVrModePackageEnabled(Context context, ComponentName requestedComponent)

Checks if the given component is enabled in user settings.

IBinder onBind(Intent intent)

Return the communication channel to the service.

void onCurrentVrActivityChanged(ComponentName component)

Called when the current activity using VR mode has changed.

Inherited methods

From class android.app.Service
From class android.content.ContextWrapper
From class android.content.Context
From class java.lang.Object
From interface android.content.ComponentCallbacks2
From interface android.content.ComponentCallbacks

Constants

SERVICE_INTERFACE

added in API level 24
String SERVICE_INTERFACE

The Intent that must be declared as handled by the service.

Constant Value: "android.service.vr.VrListenerService"

Public constructors

VrListenerService

added in API level 24
VrListenerService ()

Public methods

isVrModePackageEnabled

added in API level 24
boolean isVrModePackageEnabled (Context context, 
                ComponentName requestedComponent)

Checks if the given component is enabled in user settings.

If this component is not enabled in the user's settings, it will not be started when the system enters VR mode. The user interface for enabling VrListenerService components can be started by sending the ACTION_VR_LISTENER_SETTINGS intent.

Parameters
context Context: the Context to use for looking up the requested component.

This value must never be null.

requestedComponent ComponentName: the name of the component that implements VrListenerService to check.

This value must never be null.

Returns
boolean true if this component is enabled in settings.

See also:

onBind

added in API level 24
IBinder onBind (Intent intent)

Return the communication channel to the service. May return null if clients can not bind to the service. The returned IBinder is usually for a complex interface that has been described using aidl.

Note that unlike other application components, calls on to the IBinder interface returned here may not happen on the main thread of the process. More information about the main thread can be found in Processes and Threads.

Parameters
intent Intent: The Intent that was used to bind to this service, as given to Context.bindService. Note that any extras that were included with the Intent at that point will not be seen here.

Returns
IBinder Return an IBinder through which clients can call on to the service.

onCurrentVrActivityChanged

added in API level 24
void onCurrentVrActivityChanged (ComponentName component)

Called when the current activity using VR mode has changed.

This will be called when this service is initially bound, but is not guaranteed to be called before onUnbind. In general, this is intended to be used to determine when user focus has transitioned between two VR activities. If both activities have declared enableVrMode with this service (and this service is present and enabled), this service will not be unbound during the activity transition.

Parameters
component ComponentName: the ComponentName of the VR activity that the system has switched to, or null if the system is displaying a 2D activity in VR compatibility mode.

See also:

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.