Android Development Guide (36) -- Search

Source: Internet
Author: User

 

Preface

This chapter is the Framework Topics/Search chapter in the Android developer guide. It is translated into "Search" and the version is Android 4.0 r1. It is translated from: "dumb Prawn". Welcome to his microblog: "http://weibo.com/popapa", thanks again "dumb prawns "! We look forward to your participation in translation of Android related information, contact me over140@gmail.com.

 

Statement

You are welcome to repost, but please keep the original source of the article :)

Blog Garden: http://www.cnblogs.com/

Android Chinese translation group: http://androidbox.sinaapp.com/

 

 

Search

Translator's signature: Dummies

Translator's microblog: http://weibo.com/popapa

Version: Android 4.0 r1

Original

Http://developer.android.com/guide/topics/search/index.html

 

Topic

Create search interface

Add suggestions for recent queriesItem

Add custom suggestion items

Reference

Search configuration files

Example

With searchFunction dictionary

 

Search is the core function of Android. Users should be able to search for any data, including content on devices and the Internet. To build a unified user experience, Android provides a search framework for applications to implement the search function.

 

Figure1.The screen of the Search dialog box with Custom Search recommendations.

 

The search framework provides two search content input modes: The Search dialog box at the top of the screen and the search widget (SearchView) that can be embedded in activity layout ). In either mode, the Android system sends the search request to the specified activity that executes the search. You can also use the User-Defined search suggestion items in the search box or widget. Figure 1 shows an example of a search box with optional search recommendations.

Once a Search dialog box or widget is created, you can:

· Enable Voice Search

· Provide search suggestion items based on the user's recent request

· Provides Custom Search recommendations that match the actual data of the application

· Submit the application search suggestion item to the system-level "quick search box"

Note:Search for frameworks andNot availableThe data search API. In order to perform the search, you also need to select the corresponding API based on the data. For example, if the data is stored in the SQLite database, you should use the android. database. sqlite API to complete the search.

In addition, not all devices guarantee a dedicated "Search" button to trigger the search interface. If you use the Search dialog box or custom interface, you must provide a search button on the user interface to activate the search interface. For more information, see the submit Search dialog box.

 

The following documents show how to use the Android search framework for search:

Create search interface

How to Use the Search dialog box and search widgets in the application.

Add recommended items for recent queries

How to provide search recommendations based on the previously submitted queries.

Add custom suggestion items

How to give a search suggestion based on the custom data of the program, and submit the suggestion item to the system-level "quick search box ".

Search configuration files

Search for the configuration file reference document (other documents may have discussed the configuration file from other perspectives ).

 

 

Protect user privacy

Some measures should be taken to protect users' privacy when implementing the search function in the program. Many users consider the activities on their hands-including searches-as private information. To protect the privacy of all users, the following principles should be observed:

·Do not send personal information to the server. do not record the personal information if it is required.

Personal information refers to any information that can uniquely identify a user, such as name, email address, bill information, or other data associated with such information. If the application requires server support to complete the search, do not send personal information in the search request. For example, if you want to search for a store near a zip code, you do not have to send the user ID at the same time. You only need to send the zip code to the server. If you must send personal information, do not record this information. If it must be recorded, Please carefully protect the data and delete it as soon as possible.

·Clear historical search data to protect user privacy.

The search framework will help the program provide search suggestions related to the content you typed. Sometimes these suggestions are made based on the previous search content or other user operations. The user may not expect that his previous search content will be disclosed to other users who use this device. For example, the user shares a device with a friend. If the search suggestion provided by the application may expose the previous search activity, you should be able to clear the search history. If SearchRecentSuggestions is used, you can simply call the clearHistory () method. If you want to implement the custom recommendation function, you do not have to provide a method similar to "Clear history" in the content provider you are running.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.