Sending commands to Google Assistant from Android app

后端 未结 1 845
被撕碎了的回忆
被撕碎了的回忆 2021-01-21 04:38

In order to increase efficiency I want to send frequently used commands to Google Assistant from an Android app via script. E.g. \"Ok, Google .

This is the code I use fo

1条回答
  •  南方客
    南方客 (楼主)
    2021-01-21 05:04

    Managed to make it work:

    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);
    

    Source: StackOverflow question

    0 讨论(0)
提交回复
热议问题