简体   繁体   English

通过语音触发命令开始活动

[英]start an activity through a voice trigger command

I have been searching from last 9 or 10 days but I didn't get lucky enough to get my hands on some understandable code. 我过去9天或10天一直在搜索,但是我没有足够幸运地获得一些易于理解的代码。 I want to start my main activity through a trigger word like "ok google" or "open" my application receives the command and then performs some action. 我想通过“ ok google”或“ open”之类的触发字开始我的主要活动,我的应用程序接收到该命令,然后执行一些操作。 How can this be don, please provide a sample code. 怎么做,请提供示例代码。 Thanks very much in advance. 首先十分感谢。

So you want to have a voice command that can open your when it's not open? 因此,您想要一个语音命令,可以在未打开时将其打开吗?

The only way you are allowed to do this is to use Accessibility Service. 唯一允许您执行此操作的方法是使用辅助功能服务。 You will have to create your own service, implement the voice recognition, then user will have to manually turn the service on in their phone and based on the voice command, you can do whatever you want. 您将必须创建自己的服务,实现语音识别,然后用户将必须在手机中手动打开该服务,并且基于语音命令,您可以执行任何所需的操作。

Basically: 基本上:
Step 1) Develop Accessibility service 步骤1)开发无障碍服务
Step 2) Merge speech recognition with the service. 步骤2)将语音识别与服务合并。 Here is an example of speech recognition. 是语音识别的示例。
Step 3) User MUST turn on accessibility service 步骤3)用户必须打开辅助功能

You are basically trying to creating an App like TalkBack , but only for your own app, which is no easy task. 您基本上是在尝试创建像TalkBack这样的应用程序,但仅针对您自己的应用程序,这并非易事。 But i'm sure you can figure it out 但我相信你能弄清楚

Hope this helps. 希望这可以帮助。 Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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