从 Android 应用程序向语音助手发送命令

问题描述 投票:0回答:1

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

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

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

我找到了这个topic,它说这对于使用Google Assistant SDK的Raspberry Pi是不可能的。 Android 应用程序也一样吗?

android google-assistant-sdk
1个回答
12
投票

设法通过 Google Now 使其工作:

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问题

© www.soinside.com 2019 - 2024. All rights reserved.