![](/img/trans.png)
[英]Can Google Assistant be used to implement voice commands in an Android app?
[英]Sending commands to Google Assistant from Android app
為了提高效率,我想通過腳本從Android應用程序向Google Assistant發送常用命令。 例如,“好的,谷歌。
這是我用於從服務調用助手的代碼:
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);
資料來源: StackOverflow問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.