[英]how to send command to Google Assistant from Android
I want to start Google Assistant with a specific command interaction from my app.我想通过我的应用程序中的特定命令交互来启动 Google 助理。
I tried:我试过:
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);
It shows a web search result on google web.它显示了谷歌网络上的网络搜索结果。 It is not the result what I want.
这不是我想要的结果。
And I also tried:我也试过:
Intent intent = new Intent(Intent.ACTION_VOICE_COMMAND);
intent.putExtra(SearchManager.QUERY, "my command");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
From the above code, Google Assistant is started and ready for user voice command.从上面的代码中,Google Assistant 已启动并准备好接受用户语音命令。 "my command" dose not work.
“我的命令”不起作用。
. .
Expected result with the above code:上面代码的预期结果:
If 'my command' is "what time is it now?", the current time should be shown on the screen.如果“我的命令”是“现在几点了?”,当前时间应该显示在屏幕上。
The action should be same as when user call Google Assistant with "what time is it now?".该操作应与用户使用“现在几点了?”呼叫 Google 助理时相同。
Referred: Sending commands to Google Assistant from Android app参考: 从 Android 应用程序向 Google 助理发送命令
Any ideas?有任何想法吗?
在Google 支持处为 Google 助理设置和管理应用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.