将我的应用程序放入Google Now Phone搜索列表(Android全局搜索)

hxc*_*hxc 15 search android

我想在Google即时快速搜索框中搜索我的应用.我按照一些例子但它仍然无效.官方文件根本不清楚如何使这个案例有效.

现在在检查了这些stackoverflow问题之后,我开始想知道这个功能是否仍然可供开发人员使用?

android中的全局搜索仍可供开发人员使用吗?

如何让我的应用程序显示在Google即时的手机搜索列表中?

我确实看到一些应用程序仍然在快速搜索框设置中的"手机搜索"列表中.如果是这样,任何人都可以为我做点什么?我的可搜索配置xml如下

<searchable xmlns:android="http://schemas.android.com/apk/res/android"
    android:label="@string/app_name"
    android:hint="@string/search_hint"
    android:searchSuggestAuthority="@string/search_authority"
    android:searchSuggestIntentAction="android.intent.action.VIEW"
    android:searchSuggestIntentData="content://some_search_authority"
    android:includeInGlobalSearch="true">
</searchable>
Run Code Online (Sandbox Code Playgroud)

在这个AndroidManifest.xml文件中,我确实已经meta-data指定了SearchableActivity例如

<activity ...>
    <intent-filter>
        <action android:name="android.intent.action.SEARCH" />
    </intent-filter>
    <meta-data
        android:name="android.app.searchable"
        android:resource="@xml/searchable" />
</activity>
Run Code Online (Sandbox Code Playgroud)

Kon*_*nov 7

这是不可能的(至少,还没有).

Google音乐有一张Google即时贴,并且有类似的东西,你需要创建自己的卡.
不幸的是,它还没有公共API:Google Now集成

现在,应用程序中的卡片正在开发中,并非所有应用程序都可用.当我们能够加入更多合作伙伴时,我们会通知您.

可以做的是将您的应用程序添加到命令"播放(乐队名称)(歌曲名称)"的建议列表中:

在此输入图像描述

要实现这一点,您必须向您添加intent-fiters Activity,应该打开以AndroidManifest:

    <activity
        android:name=".MusicActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
Run Code Online (Sandbox Code Playgroud)

您可以在此处查看Google即时语音命令列表:所有Google即时语音命令的列表

我希望,这有帮助