为了提高效率,我想通过脚本从 Android 应用程序向 Google Assistant 发送常用命令。例如。 “好吧,谷歌。
这是我用于从服务调用 Assistant 的代码:
startActivity(new Intent(Intent.ACTION_VOICE_COMMAND).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
我找到了这个topic,这表明对于使用 Google Assistant SDK 的 Raspberry Pi 来说这是不可能的。 Android 应用程序也一样吗?
设法让它发挥作用:
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);
Source: StackOverflow问题
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)