android - 从 Android 应用向 Google Assistant 发送命令

标签 android google-assistant-sdk

为了提高效率,我想通过脚本从 Android 应用程序向 Google 智能助理发送常用命令。例如。 “好的,谷歌。

这是我用于从服务调用助手的代码:

startActivity(new Intent(Intent.ACTION_VOICE_COMMAND).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));

我找到了这个topic ,它表示这对于使用 Google Assistant SDK 的 Raspberry Pi 是不可能的。 Android 应用也一样吗?

最佳答案

设法让它工作:

String command = "navigate home by public transport";
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
intent.setClassName("com.google.android.googlequicksearchbox", "com.google.android.googlequicksearchbox.SearchActivity");
intent.putExtra("query", command);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //necessary if launching from Service
context.startActivity(intent);

来源:StackOverflow question

关于android - 从 Android 应用向 Google Assistant 发送命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46826826/

相关文章:

Android语音识别所有结果都在数组的一个索引中

android - 将 Google Home 响应转换到电视上的 Chromecast

python - 如何使用 Python 启用 Google Assistant API 的新 "read it"功能?

Android:具有不同 alpha 值的嵌套线性布局

android - 在 AOSP Build 上安装 Google Apps

android - Firebase Firestore : Could not reach Firestore backend (Android only)

android - 使用 Google Assistant 直接与我的 Android 应用程序对话并执行一个非常简单的任务

json - 在 Linux 上使用 gaction 更新 Google Home/Assistant 包时,Golang 运行时出现 panic ?

android - 如何使用 Facebook 应用程序从另一个 Android 应用程序发送照片