How to always launch app on Gear vr USB attachment - android

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.

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);

Related

unity android deep linking not working

Im developing a mobile app using unity and I want to deep link the mobile app to the website. I have edited the androidmanifest as shown in the developers site but even though the building process runs smoothly when i try to type the link on the browser and launch the app it does not work
<activity android:name="com.liveroom.liveroom.GalleryUpdater"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="liveroom"
android:host="liveview"/>
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
</activity>
as stated in the developers article the intent should be able to access and load the app when the uri liveroom://liveview but itt does not do so. please point my mistake, thank you
When you type on browser it will not open . to test make an html file using < a href tag then it will open.
Not every browser supports deep linking, only few browser supports deep linking, like if you want to check deep linking, use google chrome latest updated browser , so when You test deep linking using QR code it will open perticular app.
Was also not working for me. What helped was to remove android:host="(...)"
So my AndroidManifest.xml now looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<application>
<activity android:name="com.unity3d.player.UnityPlayerActivity" android:theme="#style/UnityThemeSelector" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="unitydl" />
</intent-filter>
</activity>
</application>
</manifest>

how to set launch activity for Google Play or APK installer

I have the follow manifest part about application
<application
android:allowBackup="true"
android:icon="#drawable/icon_goodrider_logo"
android:label="#string/app_name"
android:theme="#style/PingTheme" >
<activity
android:name=".passenger.ui.LicenseActivity"
android:label="#string/app_passenger_label"
android:icon="#drawable/icon_logo"
android:taskAffinity="com.city.passenger"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".driver.ui.LicenseActivity"
android:label="#string/app_driver_label"
android:icon="#drawable/icon_logo"
android:taskAffinity="com.city.driver"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and I want to set launch activity for Google Play Open button (visible after install) or APK install Open button.
Is it possible with out one more launch icon at apps?
Thanks! =)
From my experience, the Open button after the APK was installed is grayed out (disabled) when there are multiple main activities in your AndroidManifest.xml.
Interestingly enough, it seems that this is only the case for pre-ICS devices. In Ice Cream Sandwich, the Open button is clickable and the first Activity in your AndroidManifest.xml with an android.intent.action.MAIN intent filter will be opened on tap.
<activity android:name=".FirstLaunchActivity" android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.INFO" />
</intent-filter>
</activity>

My app isn't appearing in my app drawer even though it has installed

Why won't the app appear in the app drawer? It says in the App Manager that it is installed but I can't seem to open the actual app as it isn't in the app drawer. It doesn't automatically open it up once it's installed either.
Here is what is said when I choose to run on my phone (which is on Jellybean). It says the same thing when I install it to an emulator.
[2012-09-19 16:20:24 - TheForeverAloneQuiz] Performing sync
[2012-09-19 16:20:24 - TheForeverAloneQuiz] Automatic Target Mode: Several compatible targets. Please select a target device.
[2012-09-19 16:20:28 - TheForeverAloneQuiz] Uploading TheForeverAloneQuiz.apk onto device '001988a8094d8e'
[2012-09-19 16:20:28 - TheForeverAloneQuiz] Installing TheForeverAloneQuiz.apk...
[2012-09-19 16:20:31 - TheForeverAloneQuiz] Success!
[2012-09-19 16:20:31 - TheForeverAloneQuiz] /TheForeverAloneQuiz/bin/TheForeverAloneQuiz.apk installed on device
[2012-09-19 16:20:31 - TheForeverAloneQuiz] Done!
Here's the android manifest.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mikenning.foreveralonequiz"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Light.NoTitleBar" >
<activity
android:name=".Introduction"
android:label="#string/title_activity_introduction" >
<intent-filter>
<action android:name="android.intent.action.INTRO" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".QuestionOne"
android:label="#string/title_activity_introduction" >
<intent-filter>
<action android:name="android.intent.action.QUESTIONONE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Result"
android:label="#string/title_activity_introduction" >
<intent-filter>
<action android:name="android.intent.action.RESULTS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Anything I'm doing wrong?
SIDENOTE I also get errors saying that I do not need permission for the activities categorised as 'DEFAULT'. Could this be to do with it? I need it for the startActivity() in one of my clases so is it really not required?
I'm assuming that introduction is your first Activity. You need to add another action to it, like in the following code:
<activity
android:name=".Introduction"
android:label="#string/title_activity_introduction" >
<intent-filter>
<action android:name="android.intent.action.INTRO" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I know it is solved question, but this solution did not work for me and I wanted to share my solution here.
I was trying to add deep link support to my app, And in the documentation the
<intent-filter android:label="#string/filter_view_http_gizmos">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="gizmosexample"/>
</intent-filter>
I added those intent filters to my launcher activity and after app drawer stopped showing the app icon in the launcher.
So if #RaghavSood's solution above did not work, try to remove those filters or any other custom filters from the launcher activity's filters.

Android application won't launch on device

I have developed an Android application using Eclipse which works perfectly on the Android Virtual Device or when running it on my smartphone using Eclipse + USB Debugging mode enabled.
However, when I install the application on my phone using a signed apk file which resided on the sd card and try to launch it I get a "Activity not found - lsp.workshop" error, and the app won't start (lsp.workshop is the application package name).
the AndroidManifest.xml file is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="lsp.workshop"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".TwitterLogin"
android:label="#string/app_name" android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<data android:scheme="twitter" />
<data android:host="log" />
</intent-filter>
</activity>
</application>
</manifest>
What am I doing wrong? Thanks
The emulator and android with a debugger attached can behave differently then when you start an app normally. The timing is different (influences multithreading and race conditions) and other things may be affected as well.
But just to be sure:
Did you list the activity within your AndroidManifest.xml file?
Is the spelling really correct?
If those things are not the problem, then could you show some code (how do you start the activity? with an intent?) and maybe the manifest file ?
Using two intent filters instead of one solved the problem:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="twitter" android:host="log" />
</intent-filter>
When you export your apk,be sure to name it -something.apk ,ie just put the ".apk" at the end when you export the application (y)

add my TTS Engine to Android TTS Serivce like SAPI

I have developed my own TTS apps in Android. Is there any way to deploy my TTS engine into the OS instead on running the TTS apps, so that other apps can call my TTS? Something like SAPI in MS Window. SVOX can package the engine as apk and after installed, it adds new engines into the Andorid OS, not sure how can I do that same.
For your text-to-speech engine to show up in the list of available services, you'll need to add the appropriate activities and manifest entries.
For API 14 and above, you need to extend TextToSpeechService and you need to add the following to your manifest:
<service
android:name=".MyTextToSpeechService"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.TTS_SERVICE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.speech.tts"
android:resource="#xml/tts_engine" />
</service>
This references res/xml/tts_engine.xml, which should look like this:
<?xml version="1.0" encoding="utf-8"?>
<tts-engine xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="com.example.MyTtsSettingsActivity" />
You'll also need to add a variety of supporting activities. Here's what you'll be adding to your manifest:
<activity
android:name=".DownloadVoiceData"
android:theme="#android:style/Theme.Dialog" >
<intent-filter>
<action android:name="android.speech.tts.engine.INSTALL_TTS_DATA" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".CheckVoiceData"
android:theme="#android:style/Theme.Translucent.NoTitleBar" >
<intent-filter>
<action android:name="android.speech.tts.engine.CHECK_TTS_DATA" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".GetSampleText"
android:theme="#android:style/Theme.Translucent.NoTitleBar" >
<intent-filter>
<action android:name="android.speech.tts.engine.GET_SAMPLE_TEXT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".TtsSettingsActivity"
android:label="#string/tts_settings_label" >
<intent-filter>
<action android:name="android.speech.tts.engine.CONFIGURE_ENGINE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Legacy code for pre-ICS compatibility. -->
<activity
android:name=".MyTtsEngine"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.START_TTS_ENGINE" />
</intent-filter>
</activity>
<provider
android:name="com.googlecode.eyesfree.espeak.providers.SettingsProvider"
android:authorities="com.googlecode.eyesfree.espeak.providers.SettingsProvider" />
If you're planning on supporting pre-ICS versions of Android, you'll also need a shared library that conforms to a specific API.
I won't go into details of the implementation of each activity here, or into the pre-ICS API, but you can find examples in the source code for the Android port of eSpeak TTS engine:
http://code.google.com/p/eyes-free/source/browse/trunk/tts/espeak-tts/

Categories

Resources