Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从Android向Google Assistant发送命令_Android_Google Assistant Sdk - Fatal编程技术网

如何从Android向Google Assistant发送命令

如何从Android向Google Assistant发送命令,android,google-assistant-sdk,Android,Google Assistant Sdk,我想用我的应用程序中的特定命令交互启动GoogleAssistant 我试过: Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); intent.setClassName("com.google.android.googlequicksearchbox", "com.google.android.googlequicksearchbox.SearchActivity"); intent.putExtra(SearchManager.QUER

我想用我的应用程序中的特定命令交互启动GoogleAssistant

我试过:

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);
它显示了google web上的web搜索结果。这不是我想要的结果

我也试过:

Intent intent = new Intent(Intent.ACTION_VOICE_COMMAND);
intent.putExtra(SearchManager.QUERY, "my command");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
从上面的代码中,GoogleAssistant启动并准备好执行用户语音命令。“我的命令”不起作用

上述代码的预期结果:

如果“我的命令”是“现在几点?”,则屏幕上应显示当前时间

这个动作应该和用户打电话给GoogleAssistant“现在几点了?”

参考:


有什么想法吗?

为位于