从Android应用向Google智能助理发送命令
问题描述:
为了提高效率,我希望通过脚本将经常使用的命令从Android应用发送到Google智能助理。例如。 “好吧,谷歌从Android应用向Google智能助理发送命令
这是我使用从一个服务调用助手代码:
startActivity(new Intent(Intent.ACTION_VOICE_COMMAND).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
我发现这个topic,它说,这是不可能的树莓派其采用谷歌助理SDK 。它是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);