Android Wear Custom Voice Actions - android

I'm making an app that will work with Android Wear,
And I wanted to implement a command into Google's "Ok Google" option.
I saw this page:
http://developer.android.com/training/wearables/apps/voice.html
But it's related only to apps that include Activities in the Android Wear.
I wanted to ask:
Can I add custom commands? I mean, those who does not start with the word "Start"?
Can I add commands that will do another thing than just opening the app? Like running a method?
If it's not the place to ask this, can you give me an email/link to Google Developers help/support? thanks.

For apps that run on the Android Wear Device:
No, the list of system-provided voice actions is fixed (and listed here). You can set your application to be able to respond to them (for example, to take a note), but you cannot add new ones.
Yes. When already inside your app, you you can use startActivityForResult() using the ACTION_RECOGNIZE_SPEECH to get voice input. You could then use the returned string to execute whatever you want.
Meanwhile, if you're just displaying notifications from an Android app running in a handheld, then you cannot presently have voice actions at all (at least in a literal sense). What you may have, though, is a notification action that requests voice input. That input will then be passed as an extra in the Intent that is delivered to the app in the handheld.

Related

Can we handle voice command from assistant widget?

I'm able to integrate Android widgets with Google Assistant. And want to have some voice command experience.
For example the CREATE_CALL intent, if user is trying to call Alice by saying call Alice with some app, and if there are 2 Alice in my app, is it possible for me to response with a widget showing 2 Alice, and asking user by voice, and user can choose which one to actually call, all by voice? Can it be done by SpeechRecognizer API?
Broadly speaking, App Actions do not have a voice conversation experience. There are some tricks you can pull that might head in that direction, but they are largely outside of the App Action Widget experience itself.
Can I respond with a widget showing that there are multiple matches?
Yes, you can send back a Control Widget that might allow them to choose which user they mean.
Can they speak which user?
Probably not in the way you're thinking. To use your example, they can re-invoke the CREATE_CALL BII using any of the phrases, but you can't prompt them with "Who did you mean, exactly?" and for them to just say the name.
Can I use the SpeechRecognizer API?
Not as part of a widget.
Widgets get embedded in the conversation with the Assistant.
In theory (and this is on my list to eventually test and figure out), you should be able to deep link to an Android Intent in cases such as this and open a view. While there, you could use SpeechRecognizer or just open the microphone to send audio somewhere. But this isn't done using the Widget itself.
In this scenario, SpeechRecognizer just does the Speech To Text (STT) or Automatic Speech Recognition (ASR) part of the processing. To actually match this up to phrases to determine an Intent, you would need a Natural Language Understanding (NLU) module such as Dialogflow. (But you may not need the SpeechRecognizer in that particular case, since Dialogflow can also take an audio stream to do the ASR part for you.)

How to detect if another application is open in Flutter?

[EDITED]
I want to create an application that discourages the usage of social media applications. Like if they open Instagram or something then the Flutter app will know.
How would I detect if another application (Such as Instagram or Twitter) is open when my Flutter app is opened?
If this is difficult to implement in Flutter, can anyone suggest some other languages or code for this functionality?
Thanks!!
It is possible at least on Android. I do not program for IOS so I can't say for sure. As #Gaurav pointed out, the solution will need to be custom-made and it probably won't be specific to Flutter. If you are willing to work outside Flutter than it is possible.
Once again, the following solutions are for Android devices:
Solution 1: Since you are targeting social media apps you can lookup the public intents of each app (i.e. Facebook, WhatsApp, etc...) find out the names of the intents they are broadcasting and add a broadcast receiver in your application. Many will say this is not a good idea because the app developer's themselves could change the intents and that you shouldn't listen for anything that hasn't been declared for public use. They are probably right, but this discussion is about how to detect the other apps launching and this method works.
Simply google how to add a broadcast receiver, a good example can be found here.
There are websites that contain databases for a lot of broadcast intents for popular Android applications, but if you have trouble finding the name of a particular one then I'd suggest using ADB to find it. For example, Facebook would be:
adb shell pm dump com.facebook.katana | grep ' filter' | cut -d ' ' -f 12
In some versions of Android broadcast intents do not work, however registering it in the application has worked pretty well for myself.
Once you have a listener setup properly, then you can detect the app when the user launches it and process it accordingly.
Solution 2: You could monitor the processes on the Android device via "Process" and/or "PackageManager" and see when one of the social media applications popup. This method is not very reliable because apps are on all the time and just because they're in the process list doesn't mean they are actively being used.
Solution 3: Once again, this is a very "hacky" solution, but you could listen to the logs on each device. Basically get the output of console logs, read the last 100 lines and see if the app is doing something. If so, then you may be able to determine if the app is active. The biggest problem with this solution (besides trying to read logs on all your user's devices) is that this is not an instant solution and may require special privileges depending on the device you're working on. You would also probably need to setup a service that actively listens and reads the logs, which might cause some significant battery usage.

Android URL intent deep linking like iOS

The iOS OS provides this back button on the top of an app that was opened via custom URL schemes. This button generally displays the name of the app that launched the custom URL scheme. This could be seen in the screenshot, "Return to Search". Search is the app that opened the app in foreground now.
I was wondering if we could customise the android action bar, to have a similar effect when my app is opened thorough custom URL intents.
NOTE - I know iOS do not have a back button, and hence this was developed. But displaying the app name, makes it explicit that my app was opened via URL intent by this app. It provides higher visibility to the users.
I was wondering if we could customise the android action bar, to have a similar effect when my app is opened thorough custom URL intents.
No, insofar as you have no way of knowing who started your activity.
The is no way of doing it automatically, but:
Android API lvl 22 introduced a new method getReferrer() to return information about who launched this activity.
By default, it will return a android-app: referrer URI.
For instance, Chrome beta will use android-app//:com.chrome.beta as referrer when launching an app.
You could therefore use this value (it might not be 100% trusted) and query the package manager to get the application label.
You can collect some data that manages user experience, but only in your own environment. For example N apps that interact with each other. If you think closely you will see that knowing who wakes your app up doesn't make sense since the caller can use a broadcast, for instance.

Continuous voice recognition on Android

I've implemented a relatively simple test application for a customer who owns a container repair facility. His aim is to deliver to his operators a tool with (possibly) voice interaction. The app basicly works well, using Google's Speech API. The annoying problem are the notification sounds when you launch the recognition intent and the subsequent timeout notification if the user doesn't speak within 4 seconds. I'm intercepting all the errors, so I can relaunch the recognizer, but it's not so comfortable hearing this couple of notification every 4 seconds, especially when you're awaiting the next container to check. A partial workaround could be the implementation of a sound trigger like the "Ok Google" feature found, for example, on my Samsung S6, but I'm not able to find info about that. The app is written with Xamarin, but it has been already ported under Android Studio in order to test the Nuance library, so if there isn't a chance for implementing "Ok Google" trigger under Xamarin, also any java suggestion would be very welcome. Obviously I don't need "Ok Google" but anoter trigger, like "inizio" or "start check", that is a user-defined trigger (or set of triggers).
Thanks.
Rodolfo

Android: How to program changes to the standard android sms GUI

I want to write an android app that changes the android standard message sms GUI giving it an extra send button. The one send button should be the usual one and the other should be the one that uses my application to send the message. How do I add this extra button in the android standard sms message GUI? Anyone got an example code on how to do this?
Kind regards
Benjamin
Ok, this you Cannot do for phones which are in the market. You will need to grab hold of the sources and come up with a custom ROM for users to flash.
However, as another option, you can build your own SMS application and let users install so. When users need to send a SMS, they will be asked whether we default/your app needs to be used. This way is a much cleaner approach and more reachable to users.

Categories

Resources