How to add your app to the android quick search box and search as needed.

Source: Internet
Author: User

In search settings, the searchable items contains five checked items: Web, apps, contacts, messaging, and music. Obviously, this does not satisfy all our needs, and there is no end to our user desires. >_<|| ~~~ The following describes how to add our own apps to the quick search box to become a searchable items.

Local searches cannot mention contentprovider and contentresolver. Our app uses contentprovider to publish its own data, allowing other people's apps to obtain their own data information. At the same time, obtain the remote access method of the corresponding contentprovider through contentresolver. Contentprovider and contentresolver are connected through the Binder Mechanism.

Android has a searchmanager module dedicated to processing search requests. Each app must be used to start the search function.

If you want to write an app, you can also use a third-party app. If you want to try it, you can directly use development/samples/searchdictionary as an example. For more information, see.

In androidmanifest. xml of our app, you need to register intent and Res/XML/searchable. xml.

<Intent-filter> <br/> <action Android: Name = "android. intent. action. search "/> <br/> <category Android: Name =" android. intent. category. default "/> <br/> </intent-filter> </P> <p> <meta-data Android: Name =" android. app. searchable "<br/> Android: Resource =" @ XML/searchable "/>

 

You also need to disclose your data for quick search box.

<! -- Provides search suggestions for words and their definitions. --> <br/> <provider Android: Name = "dictionaryprovider" <br/> Android: Authorities = "Dictionary" <br/> Android: syncable = "false"/>

 

In Res/XML/searchable. XML, note that the searchsuggestauthority and androidmanifest. xml must correspond to each other,

The key sentence for importing an app to qsb is as follows:
Android: searchsettingsdescription = "@ string/settings_description"
Android: includeinglobalsearch = "true"

<Searchable xmlns: Android = "http://schemas.android.com/apk/res/android" <br/> Android: Label = "@ string/search_label" <br/> Android: searchsettingsdescription = "@ string/settings_description" <br/> Android: includeinglobalsearch = "true" <br/> Android: searchsuggestauthority = "Dictionary" <br/> Android: searchsuggestintentaction = "android. intent. action. view "> <br/> </searchable>

 

 

 

 

Compile and generate APK push. In Search setting, manually select your application options.


Under package/apps/quicksearchbox/tests/, there are three interesting apps that can be directly added to quicksearchbox.

To run the tests use the command:
"ADB shell am instrument-W com. Android. quicksearchbox. Tests/Android. Test. instrumentationtestrunner"



Enrich the qsb ~

 

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.