从 Android 应用启动我的 Google 操作
Launch my Google Action from the Android App
几天来我一直在尝试通过一个按钮打开 google 助手(完成)并发送查询以打开我的 google 操作(未完成)。到目前为止,这似乎是不可能的。有什么帮助吗?顺便说一句,我正在使用 Xamarin,但也非常欢迎 android 回答。
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);
你想达到类似GIF的效果吗?
我把Intent.ActionVoiceCommand
改成了Intent.ActionWebSearch
这是我的代码。
private void Button1_Click(object sender, System.EventArgs e)
{
Intent intent = new Intent(Intent.ActionWebSearch);
intent.AddCategory(Intent.CategoryDefault);
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);
}
为此,您不会发送基于文本的查询进行搜索。相反,您将在操作控制台中看到 Action Links.
对于给定的操作,您将看到 链接 部分。启用它后,您将获得一个 HTML 代码片段,您可以在网站甚至 Android 应用程序中使用它。
https://assistant.google.com/services/invoke/uid/<action-id>?hl=en
您可以在您的 Android 应用程序中使用此 URL,方法是打开它。这将触发智能助理捕获 URL 并打开你的操作。
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);
几天来我一直在尝试通过一个按钮打开 google 助手(完成)并发送查询以打开我的 google 操作(未完成)。到目前为止,这似乎是不可能的。有什么帮助吗?顺便说一句,我正在使用 Xamarin,但也非常欢迎 android 回答。
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);
你想达到类似GIF的效果吗?
我把Intent.ActionVoiceCommand
改成了Intent.ActionWebSearch
这是我的代码。
private void Button1_Click(object sender, System.EventArgs e)
{
Intent intent = new Intent(Intent.ActionWebSearch);
intent.AddCategory(Intent.CategoryDefault);
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);
}
为此,您不会发送基于文本的查询进行搜索。相反,您将在操作控制台中看到 Action Links.
对于给定的操作,您将看到 链接 部分。启用它后,您将获得一个 HTML 代码片段,您可以在网站甚至 Android 应用程序中使用它。
https://assistant.google.com/services/invoke/uid/<action-id>?hl=en
您可以在您的 Android 应用程序中使用此 URL,方法是打开它。这将触发智能助理捕获 URL 并打开你的操作。
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);