从快速搜索栏触发后,搜索建议会导致应用程序行为不一致

发布于 2024-09-05 06:52:03 字数 2716 浏览 2 评论 0原文

我遇到了快速搜索栏的问题,希望有人可以帮助我解决。

我的应用程序包含一个可搜索活动,用于在我的应用程序中提供搜索行为。该搜索活动旨在当单击搜索项时触发单独的 Intent,以便导致不同的活动来处理查看。在应用程序中使用时,搜索行为每次都能完美运行。

我的应用程序还包括一个用于提供搜索建议的 ContentProvider,并且还配置为允许在快速搜索栏中使用。当在应用程序本身中使用时,每次使用搜索建议时效果都很好。当从 QSB 触发时,初始搜索建议会按其应有的方式显示观看活动。然而,在那之后,对应用程序内的搜索建议的任何使用(即调出搜索并选择搜索建议)都无法触发查看应用程序。事实上,我已将调试语句放入 Searchable 活动中的每个“onXXX()”方法中,但我从未看到它们中的任何一个被触发。另一方面,当我在同一点触发标准搜索时(即输入查询字符串并按 Enter 键,而不是导航到搜索建议),搜索对话框会按预期出现,并从该列表中选择一个项目成功触发我的应用程序。

我目前不知所措,试图确定为什么会发生这种情况。任何想法

作为一些附加信息,我的清单包含以下有关可搜索活动(“.activity.SearchableActivity”)、建议提供程序(“.content.TestSuggestionProvider”)和用于显示内容的活动(“.activity.SearchableActivity”)的信息。 Activity.TestDisplayActivity"):

    <activity 
        android:name=".activity.TestDisplayActivity"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:finishOnTaskLaunch="true"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
        android:screenOrientation="landscape"
        android:configChanges="orientation|keyboardHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <meta-data android:name="android.app.default_searchable" android:value=".activity.SearchableActivity" />
    </activity>

    <activity 
        android:name=".activity.SearchableActivity"
        android:launchMode="singleTop"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
        <intent-filter>
            <action android:name="android.intent.action.SEARCH" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <meta-data android:name="android.app.searchable" android:resource="@xml/searchable"/>
    </activity>

    <provider 
        android:name=".content.TestSuggestionProvider" 
        android:authorities="com.test.provider.suggest" 
        android:syncable="false" 
        />

以下是用于进一步定义可搜索活动的设置的 XML:

<searchable xmlns:android="http://schemas.android.com/apk/res/android"
    android:label="@string/search_app_label"
    android:hint="@string/search_app_hint"
    android:searchSettingsDescription="@string/search_app_settings_description"
    android:includeInGlobalSearch="true"
    android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"
    android:searchSuggestAuthority="com.test.provider.suggest"
    android:searchSuggestIntentAction="android.intent.action.VIEW">
</searchable>

有什么想法吗?此刻我完全不知所措……

I'm running into an issue with the Quick Search Bar that I'm hoping someone can help me with.

My application includes a Searchable activity used to provide search behavior within my application. That search activity is designed to trigger a separate Intent when the search item is clicked on so as to cause a different Activity to handle the viewing. When used within the application, the search behavior works perfectly every time.

My application also includes a ContentProvider used to provide search suggestions and is also configured to allow use in the Quick Search Bar. When used within the application itself, use of the search suggestions works fine every time it is used. When triggered from the QSB, the initial search suggestion brings up the viewing activity just as it should. After that point, however, any use of the search suggestions from within the application (i.e. bringing up the search and selecting a search suggestion) fails to trigger the viewing application. In fact, I've put debug statements in every single "onXXX()" method within the Searchable activity and I never see any of them get triggered. On the flip side, when I trigger a standard search at that same point (i.e. enter a query string and hit enter, rather than navigating to a search suggestion), the search dialog comes up, as expected, and selecting an item from that list successfully triggers my application.

I'm currently at a loss trying to determine why this would be occurring. Any ideas

As as some additional information, my manifest contains the following in regards to the searchable activity (".activity.SearchableActivity"), the suggestions provider (".content.TestSuggestionProvider") and the activity used to display the content (".activity.TestDisplayActivity"):

    <activity 
        android:name=".activity.TestDisplayActivity"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:finishOnTaskLaunch="true"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
        android:screenOrientation="landscape"
        android:configChanges="orientation|keyboardHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <meta-data android:name="android.app.default_searchable" android:value=".activity.SearchableActivity" />
    </activity>

    <activity 
        android:name=".activity.SearchableActivity"
        android:launchMode="singleTop"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
        <intent-filter>
            <action android:name="android.intent.action.SEARCH" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <meta-data android:name="android.app.searchable" android:resource="@xml/searchable"/>
    </activity>

    <provider 
        android:name=".content.TestSuggestionProvider" 
        android:authorities="com.test.provider.suggest" 
        android:syncable="false" 
        />

And the following is the XML used to further define the settings of the searchable activity:

<searchable xmlns:android="http://schemas.android.com/apk/res/android"
    android:label="@string/search_app_label"
    android:hint="@string/search_app_hint"
    android:searchSettingsDescription="@string/search_app_settings_description"
    android:includeInGlobalSearch="true"
    android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"
    android:searchSuggestAuthority="com.test.provider.suggest"
    android:searchSuggestIntentAction="android.intent.action.VIEW">
</searchable>

Any thoughts? At the moment I'm at a complete loss…

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文