简体   繁体   中英

Can Google Assistant be used to implement voice commands in an Android app?

I would like my Android app to perform an action by a voice command. For example, there is a button "Send a message" on the activity; the user must be able to send a message by tapping a button, or by saying "Send a message".

In Android, there is a SpeechRecognizer, but it doesn't seem to be an appropriate solution. SpeechRecognizer is good when the user enters some text by voice, but it is not designed for long listening, and it uses a dangerous RECORD_AUDIO permission.

There is Google Assistant, which works exactly as I expect. The user speaks a keyphrase ("OK Google"), then speaks some command (for example, "Start the app"), and gets what he has asked for.

Is it possible to integrate the Android app with Google Assistant in some way? An ideal scheme would be the following:

  1. When the app becomes active, it registers a keyphrase "Send a message" in Google Assistant.

  2. The user says "OK Google, send a message" which raises Google Assistant.

  3. Google Assistant recognizes "Send a message" command and sends it to the app.

  4. The app gets an Intent and performs the required action.

  5. When the app closes the screen containing the action, it unregisters the keyphrase.

Looks like this is something simple and intuitive, but I couldn't find any appropriate documentation for this feature.

Google为此实施了Actions ,但操作并不像您想象的那样顺利

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM