fbpx

GOOGLE’S SIX MAGIC LINES OF SEARCH CODE

03 Nov GOOGLE’S SIX MAGIC LINES OF SEARCH CODE

Welcome to the Weekend Tech Round-up.

With just 6 lines of code in your AndroidManifest.xml file,  Android’s on-device search opens and scours your applications for data.

The lines of code are:Move to Trash

<activity android:name=”.SearchableActivity”>

<intent-filter>

<action android:name=”com.google.android.gms.actions.SEARCH_ACTION”/>

<category android:name=”android.intent.category.DEFAULT”/>

</intent-filter>

</activity>

For developers, this coding technique allows you to integrate power functionalities in a quick and easy way. It gives users a deeper interaction with the app. Your app can receive the SEARCH_ACTION intent containing the SearchManager.QUERY with the search expression once you have implemented the 6 lines of code.

For the rest of us, this means you can perform a simple voice activated search by saying something like “Search Foursquare for a rooftop bar ” and Foursquare will be opened and the search field filled with the data requested. Any user running Google 3.5 or higher on an Android Jelly Bean+ device will be able to use this functionality.