I am working on implementing voice commands for Android Auto using media player callback methods. I am having trouble getting Auto to recognize that I am asking to play a title on my application: “Play [x] on MyApp”
. I understand that it takes a few days after being published for this command to work, but I should still be able to say “Play [x]”
while the media session is already running and it should use onPrepareFromSearch
and onPlayFromSearch
methods to search for and play content.
When I say “Play [x] on MyApp”
I get the response “I looked for [x] on MyApp on Google Play Music but it either isn’t available or it can’t be played right now”
.
When I say “Play [x]”
while my media service is running it will usually redirect me to Google Play Music.
I am able to pause, resume, skip forward and skip backward using voice commands and I see those being logged but when I try to perform a voice search neither onPrepareFromSearch
nor onPlayFromSearch
are called.
Things I have tried:
- Added an
<intent-filter>
forMEDIA_PLAY_FROM_SEARCH
to an activity in my application as to mark my application available to search for media - Implemented
onPrepareFromSearch
andonPlayFromSearch
in myMediaSessionCompat.Callback
- Added
ACTION_PLAY_FROM_SEARCH
andACTION_PREPARE_FROM_SEARCH
as supported actions. - Set the media session flags
FLAG_HANDLES_MEDIA_BUTTONS
andFLAG_HANDLES_TRANSPORT_CONTROLS
- Added support for Android Auto as per the documentation here: https://developer.android.com/training/cars/media/auto
Is there a step I am missing in order to get this to work?