13

In the Google CodeLabs example for the Voice Interaction API, an activity is defined with the following intent filter (see step 6):

<intent-filter>
    <action android:name="android.media.action.STILL_IMAGE_CAMERA" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.VOICE" />
</intent-filter>

When using the "OK Google, take a selfie" voice command, the intent is fired with the android.intent.category.VOICE category. This is shown in LogCat as:

02-26 15:32:42.423 779-6923/? I/ActivityManager: START u0 {act=android.media.action.STILL_IMAGE_CAMERA cat=[android.intent.category.VOICE] flg=0x18000000 pkg=com.example.android.voicecamera cmp=com.example.android.voicecamera/.TakePictureActivity (has extras)} from uid 10027 on display 0

In my own app, I have added the following intent filter to my voice-searchable Activity:

<intent-filter>
    <action android:name="com.google.android.gms.actions.SEARCH_ACTION" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.VOICE" />
</intent-filter>

However, if I give the "OK Google, search for computers on [my app]", the voice category does not get added to the intent:

02-26 16:17:26.722 779-14786/? I/ActivityManager: START u0 {act=com.google.android.gms.actions.SEARCH_ACTION pkg=com.my.pkg cmp=com.my.pkg/.activity.VoiceSearchActivity (has extras)} from uid 10027 on display 0

Because this category is not set correctly in the Intent, Activity.isVoiceInteraction() and Activity.isVoiceInteractionRoot() are both returning false.

Can anyone explain why this might be happening?

Thanks!

  • 4
    Hi, it seems you must publish your app to Google Play so that Google can index and recognize your app in the query. More info is in this article: http://blog.prolificinteractive.com/2015/11/06/implementing-google-voice-actions-into-your-android-app/ – anticafe Jul 05 '16 at 08:18
  • 1
    banging my head for several hours on this ; wondering why isVoiceInteraction() was always false. The Google documentation makes no mention that your app needs to be indexed prior to successful testing. Poorly played Google. – Peter Oct 20 '16 at 13:14
  • 1
    @anticafe the link you posted no longer works. Please update it and/or submit an answer to the question containing more detail – yuval Sep 26 '18 at 21:24

0 Answers0