Can someone provide an example of how to use the new AlwaysOnHotwordDetector class in Android?
I'd like to build an app, that when the app is running in the background, can detect a hotword like "next", or "back", or "pause".
Can someone provide an example of how to use the new AlwaysOnHotwordDetector class in Android?
I'd like to build an app, that when the app is running in the background, can detect a hotword like "next", or "back", or "pause".
Unless I have a huge blind spot, I don't think third-party applications can make use of this API. Its strange that
AlwaysOnHotwordDetector
(and related classes VoiceInteractionService etc.) have been granted public access.If you are building a privileged app, look through these test projects from AOSP:
AlwaysOnHotwordDetector
usage/implementation http://androidxref.com/5.0.0_r2/xref/frameworks/base/tests/VoiceInteraction/While trying to make this work, I came upon this:
AlwaysOnHotwordDetector's
constructor:The statement of interest here is:
What does
KeyphraseEnrollmentInfo#getKeyphraseMetadata(String, Locale)
do?At this point, my example project kept telling me:
Enrollment application doesn't support keyphrases
. So, digging a bit further - to support keyphrases, we need to provide additional meta-data:Additionally, we will need the
android.permission.MANAGE_VOICE_KEYPHRASES
permission. This is where the example project gets stuck:The permission required to support hotword detection is not available to third-party applications. I still can't figure out why package
android.service.voice
package has public access. Perhaps I am missing something here.