Voice input for biking app - android

I am developing an Android Wear biking app. I am trying to enable the "Ok Google, Start cycling" into my app. It works perfectly if I say it to the phone, but not to my Moto360. Also in the Android Wear app, I am unable to choose my app as the default for "Start bike ride" Any suggestions?
This is what I have in my manifest, and it is based off of Google's example.
<intent-filter>
<action android:name="vnd.google.fitness.TRACK" />
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="vnd.google.fitness.activity/biking"/>
</intent-filter>
I searched other similar questions but didn't find a result.
Thanks for your help

Providing a Wear app is a requirement for being listed in the available apps to register for a system provided voice intent on Android Wear and appear in the Android Wear application for choosing as the default for that voice action. Per the Adding Voice Capabilities training, you attach the appropriate <intent-filter> to an activity in your Wear app. One point of note if you aren't ready to provide a full Wear app is this section of the same page:
When users speak the voice action, your app can filter for the intent that is fired to start an activity. If you want to start a service to do something in the background, show an activity as a visual cue and start the service in the activity. Make sure to call finish() when you want to get rid of the visual cue.
In your case, your activity could just display a visual cue that you are launching something (say using a ConfirmationActivity with an OPEN_ON_PHONE_ANIMATION from the Wearable UI library) and then send a message to your phone app, which would then listen for that message using a WearableListenerService and start the bike ride on the phone, posting your notification.
Note that a full Wear app with more customization is going to be expected as many apps, such as Runtastic on Android Wear add quite a few more abilities that augment the standard experience. While not out yet, an upcoming release of Android Wear will be adding offline (i.e., without a phone) GPS support for Android Wear watches that have GPS ability (currently only the not yet released Sony Smartwatch 3) and of course those abilities will require a full Android Wear experience and cannot rely on a phone app (although details have not yet been released).

You need to add a launcher intent-filter to it; then, saying "OK Google, start [app name]" will start the app. The launcher filter is:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

Related

Is it possible to listen for other apps intents?

I'm trying to understand if it is possible to listen or catch other apps intents? I have two apps. App A and App B. I would like to transmit information using nfc/android beam from app A to app B and to app A on other phone. User can have both A and B apps installed or just one B app installed. Currently I have semi nfc solution working with simple manifest intent filter:
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
Only problem with this approach emulated NFC tag on other phone works 1 out of 50 times. Not very reliable, I don't know why it does not get NFC tag every time I put together two phones.
Right now I'm trying android beam solution, which reacts every time I put phones together. But the problem is that android beam nfc intent opens only Application A and if there is not application A installed it tries to open Play store. I found out that android beam sends tag with two record:
Record 1 - http://
play.google.com/store/apps/details?id=com.whatsapp
Record 2
com.whatsapp
Main main question is, how to filter for in my application B for application A intents? Can I just write in different application packages names?

Separate launcher icon for companion configuration activity of a watch face (Android Wear)

I implemented a watch face with a configuration activity on the mobile device. The configuration activity works fine when launched from within the Android Wear app.
However, I'd like to create an extra icon that launches the configuration activity like a normal app, from outside Android Wear. When I simply implement the activity as a normal app in AndroidManifest, like below, it fails to communicate with the watch.
Ideally, the extra launcher should start the configuration activity together with the Android Wear app, if it's not running already.
<activity
android:label="Companion Configuration"
android:name=".ConfigActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
It's nothing to do with the launcher icon - or really anything on the phone side.
What you need is for your Wear app to launch when data is changed in your phone-side configuration activity, and that's all set up in the wearable app. It's well documented at https://developer.android.com/training/wearables/data-layer/events.html#Listen
In your case (since your watch app isn't running yet when the phone Activity is launched), you'll probably want to subclass WearableListenerService. This will get run by the system when data is changed on the phone, and you can do whatever is appropriate for your app when that happens.
I got this working by using the Wearable.DataApi instead of the Wearable.MessageApi
I had been using the Wearable.MessageApi to update watch from phone and that requires a peerid which i guess is generated by the wear app. I put a if/then statement to check if peerid is null and if so use the DataApi instead and works from inside the wear app and from app drawer

Wear App doesn't work if the phone App isn't running or the the phone is locked

I'm working on an android wear app that exchanges some information (using the Wearable Data Layer API) with a another android app installed in the phone device .
But if the Phone app is not running or the phone is locked the information cant be exchanged.
Basically I don't wont to look to my phone when I'm using my wearable device(Smartwatch).
any solutions ?
Thank you !
You will basically need to implement a WearableListenerService. You can find more on the section With a WearableService here.
This will spin up a service on the Android device to which you can communicate to.
Don't forget to add the permission in the AndroidManifest.
<service android:name=".DataLayerListenerService">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>
Btw a handy library that gets away a lot of the boilerplate is Courier

Adding Voice Capabilities on Android Wear

I'm trying to set up my application to respond to one of the system-provided voice actions .
By following the above mentioned link I should declare, within my android wear apk, an activity that has a very specific intent filter.
In my sample application i tried to "hook" on the "Set a timer" Voice action so my AndroidManifest.xml has the following code:
<activity android:name=".wear.MyActivity2">
<intent-filter>
<action android:name="android.provider.AlarmClock.ACTION_SET_TIMER" />
</intent-filter>
</activity>
I then bundled, signed and installed the app in my phone. I then verified that the app got installed in both my phone and the watch ( LG G Watch ).
After veryfiying that everything went right i tried to see if my app was listed as "option" for the "Set timer" voice action within the "Android Wear" app. => It didn't.
I then tried rebooting both the phone and the watch and ultimately i tried the "Refresh apps" button that is shown within the "Android Wear" -> "Settings" menu.
Nothing changed. It looks like i cannot make the "Android Wear" app aware of my app so that it listens for the desired voice action and acts accordingly.
Notes:
I tried also other voice actions ( Even the one provided as example in the link - Take a note )
I tried different permutations of reboot/resync
I double checked that the android wear app was the latest compiled
Both phone and wear app share the same package name
The Activity does nothing except showing the hello world layout...
Use this intent filter instead:
<intent-filter>
<action android:name="android.intent.action.SET_TIMER"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

Air app on Android to launch another application

I have an Android AIR application (developed with Flex SDK 4.5.1) for which I need to block the Home Button, as the app is used by patients in a hospital without supervision, i.e. it is crucial that they cannot leave the app.
It seems that the only way to hijack the Home Button is to be registered as the default launcher, so that your own app gets the focus when home is pressed. This is easily achieved in the manifest, such as:
<activity android:excludeFromRecents="false">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</activity>
Now the problem is: If I do quit the application, the original launcher should be made available to the user and I think the solution would be to just start the original launcher, but how should I do that? The original Android-way of "intents" is not available in AIR and the navigatetoURL() function seems to work only for special URIs, e.g. "market://.." launches the default market app, however, I need to execute an arbitrary application...
Edit: I am referring to a mobile Android App running in this case on an Archos tablet, but it could run on any Android device with AIR installed, such as a typical mobile phone like the HTC desire. With "home button" I am referring to the respective hardware button that allows the user to switch applications (or, to be more exact, to switch to a launcher app that typically shows all the apps as icons to tap on). This "home button" functionality I need to block, as the user should not be able to easily switch to another application.
This is probably a less useful answer but disabling device buttons sounds like something that should be handled at the OS layer and not at the Application layer. Might want to have a custom build of Android for this purpose.

Categories

Resources