Search code examples
androidandroid-toolbarandroid-search

What is Searchable configuration, searchable activity?


I am designing a simple search feature for my application, I have Successfully created a search icon on the toolbar of my screen. Now I'm having problems in implementing brains (working) behind the search feature

  • Through Android's official documentation for setting up search interface, I
    came across this various procedure of creating a searchable configuration, searchable activity, ACTION_SEARCH!

  • I'm new to android development, I'm having a tough time in understanding all these concepts, Can someone explain the above procedure in simple terms?


Solution

    1. Through Android's official documentation for setting up search interface, I came across this various procedure of creating a searchable configuration, searchable activity, ACTION_SEARCH!

    2. I'm new to android development, I'm having a tough time in understanding all these concepts, Can someone explain the above procedure in simple terms?

    Well, It's easy. First, Read the Creating a Search Interface. Second, Starts from here by adding an xml in the res/xml/ project directory.

    Then, You'll need to create a Searchable Activity by following link:

    Creating a Searchable Activity

    After creating the Searchable Activity, You'll need to declare it on AndroidManifest.xml, Just add the following to your SearchableActivity:

    <activity android:name=".SearchableActivity" >
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
            </intent-filter>
            <meta-data android:name="android.app.searchable"
                       android:resource="@xml/searchable"/>
        </activity>
    

    After all these, Read this : PerformingSearch And Receive the query from your Activity when user do the searches(Like MainActivity to SearchableActivity).