android - 如何将 OK Google 语音查询连接到我的应用程序

标签 android voice

我希望我的应用程序能够对语音查询使用react。 我已按照描述正确设置“Ok Google”here .

它工作正常,但它似乎没有连接到我的应用程序。它不打开我的应用程序,而是执行常规搜索!

最佳答案

如果您有可搜索的Activity如上所述here那么你只需要将这两行添加到 <intent-filter />您的标签Activity在你的 list 中:

<action android:name="com.google.android.gms.actions.SEARCH_ACTION"/>
<category android:name="android.intent.category.DEFAULT"/>

之后您将收到SEARCH_ACTION Intent在您的应用程序中,您可以像普通搜索一样处理 Intent 。您可以通过获取 String 来访问查询额外配有 key SearchManager.QUERY来自Intent .

但是您的用户需要在 Intent 的口头查询中指定应用名称到达您的应用程序!例如:

Ok Google, search [query] on [your app name]


您可以在博客文章 here 中找到更多信息.

关于android - 如何将 OK Google 语音查询连接到我的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30140594/

相关文章:

android - 自定义语音操作

android - 安卓语音识别

C++ 从麦克风流式传输音频

android - Android 中应用程序之间的 LED 通知优先级

android - CollapsingToolbarLayout 背景图像不起作用

c# - WPF 库支持语音

安卓:谷歌语音识别服务器

android - 在 Activity 外绑定(bind)和连接 android 服务

android - "This app won' t run unless you update Google Play Services"when app is installed on real device

Android BLE 读取 Gatt 特性