androidgoogle-nowgoogle-voice-searchsearchactivity

Voice Search is not working from ok google


I have integrated voice search from ok google using below. AndroidManifest Entry :

   <activity
        android:name=".ExposedSearchActivity"
        android:launchMode="singleTask">
        <intent-filter>
            <action android:name="com.google.android.gms.actions.SEARCH_ACTION" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEARCH" />
        </intent-filter>

        <meta-data
            android:name="android.app.searchable"
            android:resource="@xml/searchable" />
    </activity>

in ExposedSearchActivity - onCreate()

  if (intent != null && intent.hasExtra(SearchManager.QUERY)) {
        String search = intent.getStringExtra(SearchManager.QUERY);
        Log.wtf("", "q=" + search);
 }

I have published the app in closed alpha on playstore. Still Activity is not getting opened from ok google. I have tried voice command like 'ok google search for salad in MyApp' or 'search for salad in MyApp'.

Although from adb it is getting opened by command as below .

adb shell am start -a com.google.android.gms.actions.SEARCH_ACTION  -e query "salad" com.abc.MyAppp

Its been 2 days when i published my app but still from google assistant or ok google voice search is not opening MyApp.


Solution

  • Answering my own question for future reference. I have copied above code from and published my app in alpha release. How to integrate searchable Activity with Ok Google voice search?

    Just remove below intent filter from the manifest and it is working for me.

         <intent-filter>
            <action android:name="android.intent.action.SEARCH" />
        </intent-filter>