I want to my app to react to voice queries. I have setup "Ok Google" properly as described here.
It is working fine, but it does not seem to be connected to my app. Instead of opening my app it just performs a regular search!
I want to my app to react to voice queries. I have setup "Ok Google" properly as described here.
It is working fine, but it does not seem to be connected to my app. Instead of opening my app it just performs a regular search!
If you have a searchable Activity
as described here then you just need to add these two lines to the <intent-filter />
tag of your Activity
in your manifest:
<action android:name="com.google.android.gms.actions.SEARCH_ACTION"/>
<category android:name="android.intent.category.DEFAULT"/>
After that you will receive the SEARCH_ACTION
Intent
in your app which you can handle just like the normal search Intent
. You can access the query by getting the String
extra with the key SearchManager.QUERY
from the Intent
.
But your users need to specify the app name in the verbal query for the Intent
to reach your app! For example:
Ok Google, search [query] on [your app name]
You can find more information in the blog post here.