android - 如何从 Android 应用向 Google 助理发送文本查询
问题描述
当我按下按钮时,我正在尝试启动 Google Assistant 并从我的应用程序发送一个文本问题(不是语音)。例如:我点击一个按钮,Google 助理会回答我的问题“今天天气怎么样?”。
这可能吗?
编辑: 当我按下按钮时,我希望 Google 助理执行一些操作并提供语音反馈。例如:“阅读明天的天气并将闹钟设置为早上 6.30”。
解决方案
看起来您可以从直接的包类名称中引用它。
String queryString = "How is the weather today?";
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
intent.setClassName("com.google.android.googlequicksearchbox",
"com.google.android.googlequicksearchbox.SearchActivity");
intent.putExtra("query", queryString);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
推荐阅读
- ruby - 在创建之前检查目录是否存在
- java - 在java中传递类对象
- javascript - 如何使用 Javascript 访问传递给锚标记的参数以获取链接按钮单击
- python - (结果, 消耗) = self._buffer_decode(data, self.errors, final) 错误
- c - Paho MQTT C 客户端库中的错误
- android - 无法设置会话
- javascript - 运行一次后,您可以更改 javascript 函数中的语句吗
- javascript - 带有打字稿的量角器中的下拉菜单
- angular - 如何在角度 4 中路由后显示烤面包机
- apache-spark - spark应用程序中应该有多少最小驱动程序内存?