【发布时间】:2020-01-15 07:03:52
【问题描述】:
我想通过我的应用中的特定命令交互来启动 Google 助理。
我试过了:
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
intent.setClassName("com.google.android.googlequicksearchbox", "com.google.android.googlequicksearchbox.SearchActivity");
intent.putExtra(SearchManager.QUERY, "my command");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
它在谷歌网络上显示网络搜索结果。这不是我想要的结果。
我也试过了:
Intent intent = new Intent(Intent.ACTION_VOICE_COMMAND);
intent.putExtra(SearchManager.QUERY, "my command");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
通过上面的代码,Google Assistant 已启动并准备好接受用户语音命令。 “我的命令”不起作用。
.
上述代码的预期结果:
如果“我的命令”是“现在几点了?”,当前时间应该显示在屏幕上。
该操作应该与用户使用“现在几点了?”调用 Google Assistant 时的操作相同。
推荐人:Sending commands to Google Assistant from Android app
有什么想法吗?
【问题讨论】:
标签: android google-assistant-sdk