Version 3.5 of the Google for Android application includes a new API that developers can take advantage of to activate “Ok Google” functionality within their own apps. According to the Android developer blog, software makers can add a few lines of code to their app to enable users to search it using a global voice command.

Once the feature has been integrated into an app (Talon, for example), users will be able to say things like “Ok Google, search for 9to5google in Talon” to trigger a search for that term within Talon.

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.

XYcombinedSmall

The feature is available to all users on Android Jelly Bean and higher running the latest version of the free Google app. It currently only supports devices set to English.

About the Author