OK Google search actions causes isVoiceInteraction() to always return false

本小妞迷上赌 提交于 2019-12-03 10:20:20

问题


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!

来源:https://stackoverflow.com/questions/35642854/ok-google-search-actions-causes-isvoiceinteraction-to-always-return-false

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!