【问题标题】:Global search not working as expected in Android 4.4全局搜索在 Android 4.4 中无法按预期工作
【发布时间】:2013-11-15 13:15:26
【问题描述】:

我有一个应用程序,它有两个扩展 SearchRecentSuggestionsProvider 的搜索建议提供程序,并且我已在清单文件中正确设置它,并使用以下 Intent 过滤器和元数据:

<intent-filter>
   <action android:name="android.intent.action.SEARCH" />
</intent-filter>

<meta-data
   android:name="android.app.searchable"
   android:resource="@xml/searchable_tv" />

可搜索资源包括android:includeInGlobalSearch="true",应该没问题。

我显然也有一个提供者:

<provider
   android:name="com.miz.contentprovider.TvShowContentProvider"
   android:authorities="com.miz.contentprovider.TvShowContentProvider"
   android:exported="true" />

这一切都在使用 Google 搜索应用程序的 Android 4.3 中运行良好,但我刚刚将我的所有设备更新到 Android 4.4,我不再能够在我的应用程序中搜索内容。在操作系统更新之前运行的其他应用程序也是如此,例如 Google Play 音乐。

我在 XDA 开发人员上找到了一个帖子,如果它有帮助,也提到了这一点:http://forum.xda-developers.com/showthread.php?p=47472102

有谁知道发生了什么或如何解决?

更新:我可以确认它只发生在搭载 Android 4.4 的设备上。我已经使用最新的 Google 搜索更新在 Android 4.3 设备上进行了测试,它按预期工作。看起来这是 Google 更新中的错误。

【问题讨论】:

  • Google Chrome 应用确实出现在列表中。
  • 好像只显示了测试版。
  • 表明它本身不是一个错误,但可能是他们默默地收紧了过滤器。
  • 我查看了最新的 Chrome 测试版应用的清单文件,没有发现任何差异。他们在 4.4 上更改过滤器没有任何意义,但在 4.3 上保持不变。
  • 链接到带有报告的问题跟踪器页面:code.google.com/p/android/issues/detail?id=62251。不过,他们这边的任何人都没有承认这一点。

标签: android android-4.4-kitkat android-search


【解决方案1】:

我在 AOSP 中发现了这个提交,这可能是相关的: https://android.googlesource.com/platform/packages/apps/QuickSearchBox/+/ecf356c15143ab0583c64682de16d94a57f7dd1c

提交消息告诉我们,由于性能原因,此功能已被删除(这可能是也可能不是真的,因为它引用了内部票证 ID,而我在官方 bugtracker 上没有找到与此相关的问题) .

【讨论】:

  • 看起来这就是答案。可悲的是。
  • 如果你真的依赖这个功能,不管实现,你总是可以安装应用程序“QuickSearch”(id=de.jars.android.quicksearch)。这个应用程序以某种方式模拟了电话搜索机制,因此您仍然可以搜索您的应用程序。缺点是:这个应用有广告软件,在现代设备上看起来很丑,因为它以 Android 2.x 风格为主题,没有针对平板电脑进行优化。
【解决方案2】:

我咨询了 Google 的联系人,App Indexing 正在替换它。将更新文档以显示此功能已弃用,如果没有系统级权限(如 iDev 上面所示),则无法让此功能在 Kit Kat 上运行。

【讨论】:

  • 我并不是说这不是真的,但我希望不是。并非所有应用程序都能使用该功能,而且它肯定不会取代全局设备搜索。
  • 我同意。很高兴能够在设备搜索中公开我们的应用 =\
  • 这个答案提供了一个链接来确认你所说的,所以我赞成你的并接受另一个:stackoverflow.com/a/21627271/762442
  • 我希望不是这样,但 App Indexing 似乎是未来。我不确定如果我们没有一个可以实际进行应用索引的网站,我们会做什么......
【解决方案3】:

自上次更新 (v31) 以来,Google Chrome 现在显示为可搜索的应用程序。

系统应用:

试试这样

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.globalsearch" android:sharedUserId="android.uid.shared">
    <uses-permission android:name="android.permission.GLOBAL_SEARCH" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SET_PREFERRED_APPLICATIONS" />
    <application android:label="@string/global_search" android:process="android.process.acore">
        <activity android:name=".GlobalSearch" android:permission="android.permission.GLOBAL_SEARCH_CONTROL" android:stateNotNeeded="true" android:theme="@android:style/Theme.NoDisplay" android:excludeFromRecents="true">
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <!-- This must be higher than the default priority (0), which
is what GoogleSearch uses. -->
            <intent-filter android:priority="500">
                <action android:name="android.search.action.GLOBAL_SEARCH" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
        </activity>
        <activity android:name=".SearchSettings" android:label="@string/search_settings">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.search.action.SEARCH_SETTINGS" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <provider android:name=".SuggestionProvider" android:authorities="com.android.globalsearch.SuggestionProvider" android:permission="android.permission.GLOBAL_SEARCH_CONTROL" />
        <provider android:name=".StatsProvider" android:authorities="com.android.globalsearch.stats" android:permission="android.permission.GLOBAL_SEARCH_CONTROL" />
        <meta-data android:name="android.app.default_searchable" android:value=".GlobalSearch" />
    </application>
</manifest>

【讨论】:

  • 据我所知,android.permission.GLOBAL_SEARCH 权限是用于系统应用程序的,不能被第三方应用程序使用,所以没有尝试过,我很确定不会不行。
  • @MichellBak 您是否尝试使用 Android 4.4 示例 SearchableDictionary。它对我有用
  • android.permission.GLOBAL_SEARCH from /frameworks/base/core/res/AndroidManifest.xml: &lt;permission android:name="android.permission.GLOBAL_SEARCH" android:permissionGroup="android.permission-group.SYSTEM_TOOLS" android:protectionLevel="signature|system" /&gt; 所以实际上这个权限不会被授予。 @iDev 你检查过 LogCat/PackageManager.checkPermission 以确保你的应用没有被拒绝这个权限吗?
猜你喜欢
  • 2023-04-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多