接收来自Google即时的搜索 [英] Receive search from Google Now

查看:119
本文介绍了接收来自Google即时的搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我尝试实施此方法-语音搜索和您的应用之间最快的路线

So I tried to implement this - The fastest route between voice search and your app

到目前为止,我有...

What i have so far is...

清单中

<activity android:name=".MainActivity">
<intent-filter>
    <action android:name="com.google.android.gms.actions.SEARCH_ACTION"/>
    <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

在MainActivity中:

In MainActivity:

if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        editText.setText(query);

}

如果我在Google即时中输入应用名称,则会显示该应用.如果我打开它,则什么也没有发生,因此我没有收到搜索词(应用程序名称).

If I type my app name in Google Now, the app is shown. If I open it nothing happens, so I didn't receive the search term (the app name).

如何像帖子中描述好吧Google,在MyApp上搜索披萨"那样实现?

How do I implement like how the post has described "Ok Google, search pizza on MyApp"?

推荐答案

每个

好吧Google,在Eat24上搜索比萨

好吧Google,在TripAdvisor上搜索毛伊岛的酒店

Ok Google, search for hotels in Maui on TripAdvisor

您会注意到,加粗部分是将正确格式的成功语音搜索发送到您的应用后,您的应用收到的搜索字词.

You'll note the bolded portion is the search term your app receives when a successful voice search in the correct format is sent to your app.

这篇关于接收来自Google即时的搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆