2017-10-19 107 views
-1

爲了提高效率,我希望通過腳本將經常使用的命令從Android應用發送到Google智能助理。例如。 「好吧,谷歌從Android應用向Google智能助理髮送命令

這是我使用從一個服務調用助手代碼:

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

我發現這個topic,它說,這是不可能的樹莓派其採用谷歌助理SDK 。它是Android應用程序的相同

回答

1

管理,使其工作:

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 question

相關問題