Skip to content Skip to sidebar Skip to footer

Why Getvoiceinteractor () Returns Null?

I'm trying to get VoiceInteractor, but the getVoiceInteractor() method always returns null. In the manifest, I wrote the following:

Solution 1:

The documentation seems a bit unclear, but I found the following clues:

  • startLocalVoiceInteraction() seems to be needed to be able to get the VoiceInteractor
  • onLocalVoiceInteractionStarted() seems to indicate when you can call getVoiceInteractor
  • The last clue came from onGetDirectAction where it states:

    To get the voice interactor you need to call getVoiceInteractor() which would return non null only if there is an ongoing voice interaction session

This means your code should look something like this:

publicclassYourActivityextendsActivity {
  publicvoidonCreate(Bundle savedInstanceState) {
    startLocalVoiceInteraction(newBundle());
  }

  @OverridepublicvoidonLocalVoiceInteractionStarted() {
    getVoiceInteractor(); // Should be non-null here
  }
}

Post a Comment for "Why Getvoiceinteractor () Returns Null?"