page.title=Search @jd:body

Topics

  1. Using the Android Search Dialog
  2. Adding Recent Query Suggestions
  3. Adding Custom Suggestions

Reference

  1. Searchable Configuration

See also

  1. Searchable Dictionary sample app

The ability to search is considered to be a core user feature on Android. The user should be able to search any data that is available to them, whether the content is located on the device or the Internet. This experience should be seamless and consistent across the entire system, which is why Android provides a simple search framework to help you provide users with a familiar search dialog and a great search experience.

Android's search framework provides a user interface in which the user can perform a search and an interaction layer that communicates with your application. This way, you don't have to build a search box that the user must find in order to begin a search. Instead, a custom search dialog will appear at the top of the screen at the user's command. The search framework will manage the search dialog and when the user executes their search, the search framework will pass the query text to your application so that your application can begin a search. The screenshot to the right shows an example of the search dialog (using search suggestions).

Once your application is set up to use the search dialog, you can:

The following documents will teach you how to use the search dialog in your application:

Using the Android Search Dialog
How to set up your application to use the search dialog for searches.
Adding Recent Query Suggestions
How to show suggestions based on queries previously used in the search dialog.
Adding Custom Suggestions
How to show suggestions based on custom data from your application and offer your suggestions in the system-wide Quick Search Box.

Also, the Searchable Configuration document provides a reference for the searchable configuration file (though the above documents also discuss the configuration file in terms of specific behaviors).

Note: The search framework does not provide APIs to perform searches on your data. Performing actual searches is a task that you must accomplish using APIs appropriate for your data, such as those in {@link android.database.sqlite} if your data is in an SQLite database.

Protecting User Privacy

When you implement search in your application, you should take steps to protect the user's privacy whenever possible. Many users consider their activities on the phone, including searches, to be private information. To protect the user's privacy, you should abide by the following principles: