By Jarek Wilkiewicz, Developer Advocate, Google Search
How many lines of code will it take to let your users say Ok Google, and search for something in your app? Hardly any. Starting today, all you need is a small addition to your
AndroidManifest.xml in order to connect the Google Now
SEARCH_ACTION with your searchable activity:
<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>
Once you make these changes, your app can receive the
SEARCH_ACTION intent containing the
SearchManager.QUERY extra with the search expression.
At Google, we always look for innovative ways to help you improve mobile search and drive user engagement back to your app. For example, users can now say to the Google app: “Ok Google, search pizza on Eat24” or “Ok Google, search for hotels in Maui on TripAdvisor.”
This feature is available on English locale Android devices running Jelly Bean and above with the Google app v3.5 or greater. Last but not least, users can enable the Ok Google hot-word detection from any screen, which offers them the fastest route between their search command and your app!
Android Developers Blog