2

An Android application for Gear VR using Samsung S6 and S7. Following implementation is for auto launch on mobile insertion to VR.
AndroidManifest.xml

<activity
         android:name=".SplashActivity"
         android:theme="@style/SplashTheme"
         android:launchMode="singleTask"
         android:excludeFromRecents="true"
         android:configChanges="orientation|keyboardHidden|screenSize"
         android:clearTaskOnLaunch="true"
         android:screenOrientation="landscape"
         android:stateNotNeeded="true">

    <intent-filter>                    
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.LAUNCHER" />
    <category android:name="android.intent.category.INFO" />

    </intent-filter>
    <intent-filter> <action android:name="android.intent.action.proximity_sensor"          /> </intent-filter>
    <intent-filter> <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /> </intent-filter>
    <intent-filter> <action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" /> </intent-filter>
    <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
                        android:resource="@xml/device_filter" />
    </activity>

device_filter.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <usb-device vendor-id="04e8" product-id="07d2" /> 
</resources> 

It works but there is problem with Oculus app, sometime my app launch before Oculus app and other time Oculus app appear but my app doesn't launch.

Sometime when our app is open before mounting to VR Oculus app crash saying "Unfortunately, Oculus Home has stopped." due to conflict and system shows dialog.

Qamar
  • 4,959
  • 1
  • 30
  • 49
  • By simply putting this into your Empty activity you can experience the problem. Sometime Samsung s6 will show dialog with check box "Use by default for this USB device" – Qamar May 12 '16 at 12:08
  • 1
    I thought the app had to be approved by the store before you could launch via Oculus app? – Robert May 18 '16 at 14:28
  • You right, We are in testing phase. To solve this problem I have write background service that start after device insertion broadcast and make sure our app is running. so user doesn't face much problem now. – Qamar May 20 '16 at 08:36
  • What's the `product-id="07d2"` stands for? – mosquetero May 31 '16 at 15:46
  • @mosquetero it's Samsung Gear VR product id for USB identification – Qamar Jun 02 '16 at 10:25
  • @Robert approval is not required. you need to [this](http://www.gearvrf.org/bin/view/GearVRfDeveloperGuide/GearVRfDevGuide200Start#SampleApps) way – Qamar Jun 02 '16 at 10:28
  • @Qamar Thanks for sharing. – ZaEeM ZaFaR Jun 02 '16 at 10:34
  • @Qamar please I need to know how can I keep my app running? I face a problem each time I attach the device to the Gear vr USB, my activity is gone black and Oculus home is started. Once deacttached, it returns back to my app. – Amani Elsaed Nov 24 '16 at 12:43

1 Answers1

0

Those docs are helpful :) https://developer.android.com/guide/topics/connectivity/usb/host.html

For example this is how we can get details about attached device.

UsbDevice device = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);