Launch my Google Action from the Android App

Quique Fernández Serra :

I've been trying for some days to open the google assistant with one button (done) and sending a query to open my google action (not done). This seems impossible so far. Any help? Btw, I am using Xamarin, but android answers are very welcomed too.

        Intent intent = new Intent(Intent.ActionVoiceCommand);

        String queryString = "Talk to my google action";
        intent.SetClassName("com.google.android.googlequicksearchbox",
                            "com.google.android.googlequicksearchbox.SearchActivity");
        intent.PutExtra("query", queryString);
        intent.SetFlags(ActivityFlags.NewTask);

        StartActivity(intent);
Nick Felker :

To do this, you wouldn't send a text-based query to search. Rather, in the Actions Console you will see Action Links.

For a given Action, you will see the Links section. When you enable it, you will be given an HTML code snippet that you can use on a website or even in an Android app.

https://assistant.google.com/services/invoke/uid/<action-id>?hl=en

You can use this URL in your Android app by opening it. This will trigger the Assistant to capture the URL and open your Action.

String url = "https://assistant.google.com/services/invoke/uid/<action-id>?hl=en";
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);

enter image description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=175103&siteId=1