Reputation: 382
I'm trying to start Google Assistant and send a text question (not voice) from my app when I press a button. For example: I click a button, and the Google Assistant answer to my question "How is the weather today?".
Is this possible?
EDIT: When I press a button I want the Google Assistant to do some actions and give a spoken feedback. For example: "Read the weather for tomorrow and set the alarm to 6.30 am".
Upvotes: 3
Views: 2547
Reputation: 1825
If you're already using the Assistant SDK, it's pretty simple. Just replace AudioInConfig with a text query. Here's how I do it:
AssistConfig config = AssistConfig.newBuilder()
.setTextQuery("Your text query goes here!")
//.setAudioInConfig(audioInConfig)
.setAudioOutConfig(audioOutConfig)
.setDeviceConfig(deviceConfig)
.setDialogStateIn(dialogStateIn)
.setScreenOutConfig(screenOutConfig)
.build();
AssistRequest request = AssistRequest.newBuilder().setConfig(config).build();
Then send the request to the server over gRPC and you'll get a spoken response back.
Upvotes: 0
Reputation: 4338
It looks as though you can reference it from a direct package class name.
String queryString = "How is the weather today?";
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
intent.setClassName("com.google.android.googlequicksearchbox",
"com.google.android.googlequicksearchbox.SearchActivity");
intent.putExtra("query", queryString);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Upvotes: 2