正在从 Android 应用向 Google 智能助理发送指令

Sending commands to Google Assistant from Android app

为了提高效率,我想通过脚本从 Android 应用程序向 Google 助手发送常用命令。例如。 “好的,Google .

这是我用于从服务调用助手的代码:

startActivity(new Intent(Intent.ACTION_VOICE_COMMAND).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));

我找到了这个 ,它说这对于使用 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);

来源: