从Android应用程序向Google Assistant发送命令 [英] Sending commands to Google Assistant from Android app
本文介绍了从Android应用程序向Google Assistant发送命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为了提高效率,我想通过脚本从Android应用程序向Google Assistant发送常用命令.例如. 好吧,谷歌.
In order to increase efficiency I want to send frequently used commands to Google Assistant from an Android app via script. E.g. "Ok, Google .
这是我用于通过服务呼叫助手的代码:
This is the code I use for calling Assistant from a Service:
startActivity(new Intent(Intent.ACTION_VOICE_COMMAND).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
我找到了这个主题 ,这表明使用Google Assistant SDK的Raspberry Pi无法做到这一点. Android应用程序也一样吗?
I have found this topic, which says that this is not possible for Raspberry Pi which uses Google Assistant SDK. Is it the same for Android apps?
推荐答案
设法使其起作用:
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问题
这篇关于从Android应用程序向Google Assistant发送命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文