# Interpreting voice results for Android media apps in cars

DevFeed: [Interpreting voice results for Android media apps in cars](<https://devfeed.tech/articles/interpreting-voice-results-for-android-media-apps-in-cars-25891.md>)

Original publisher: [Read original article](<https://proandroiddev.com/interpreting-voice-results-for-android-media-apps-in-cars-f36d7bdb26e1?source=rss-1331e67af4e1------2>)

Author: Danny Preussler

Published: 2022-01-10T21:33:42Z

Content type: tutorial

Language: en

Sources: [Danny Preussler](<https://devfeed.tech/sources/stories-by-danny-preussler-on-medium.md>)

Topics: [Android Auto](<https://devfeed.tech/topics/android-auto.md>), [Android](<https://devfeed.tech/topics/android.md>), [media3](<https://devfeed.tech/topics/media3.md>), [Android Testing](<https://devfeed.tech/topics/android-testing.md>)

Tags: [actions](<https://devfeed.tech/tags/actions.md>), [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-auto](<https://devfeed.tech/tags/android-auto.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [cars](<https://devfeed.tech/tags/cars.md>), [google-assistant](<https://devfeed.tech/tags/google-assistant.md>), [integration](<https://devfeed.tech/tags/integration.md>), [media](<https://devfeed.tech/tags/media.md>), [voice](<https://devfeed.tech/tags/voice.md>)

## AI overview

For Android Auto media searches, the excerpt reports that Assistant calls `MediaSessionCompat.Callback.onPlayFromSearch()` with the remaining query, but the documented `MediaStore.EXTRA_MEDIA_FOCUS` check does not distinguish artist, album, or track: it says the received focus is always `vnd.android.cursor.item/*`. The suggested workaround is to read the non-null `EXTRA_MEDIA_ARTIST`, `EXTRA_MEDIA_ALBUM`, and `EXTRA_MEDIA_TITLE` values from the callback bundle to identify the requested entities. The author notes the cause is unclear and recommends testing the implementation, since documented behavior may not match reality.

## Source excerpt

When working on the Android Auto integration for SoundCloud, I stumbled upon an interesting issue. When it comes to implementing voice actions, things you read in the documentation might differ a bit from reality. Voice commands are very critical while driving a car. You want the driver to keep looking at the street, keep his hands on the steering wheel, instead of interacting with any screen. This is why when building for Android Auto, Automotive OS, and Assistant Driving Mode you have to support basic voice searches. For a music app like ours, the idea is simple. A user can say something like: "Play Moderat on SoundCloud" Under the hood The Assistant will break down our sentence for interpretation: "<Play> <Moderat> <on SoundCloud>" The verb (Play) and the app (SoundCloud) in the above command were meant for the system. It will then wake up the app mentioned (if it declared auto support via manifest) and, as we asked for verb "Play", the method MediaSessionCompat.Callback.onPlayFromSearch() will be called with the remaining query ("Moderat") as the argument. This query of "what to play" can still mean different things though. How do you know if Moderat is a band or a song? Don't worry, the Assistant will help us also here. It already got some idea what our query could mean, if we asked for an artist, an album, or a specific track. But be aware, it behaves slightly differently than officially documented. According to documentation we are supposed to write code like this: val mediaFocus = extras?.getString(MediaStore.EXTRA_MEDIA_FOCUS) if (mediaFocus == MediaStore.Audio.Artists.ENTRY_CONTENT_TYPE) { isArtistFocus = true artist = extras.getString(MediaStore.EXTRA_MEDIA_ARTIST) We are suppose to check for a bundle entry with the key MediaStore.EXTRA_MEDIA_FOCUS . This will give us a hint on how best to interpret the query. The value of the constant MediaStore.EXTRA_MEDIA_ARTIST checked above is vnd.android.cursor.item/artist and there are similar constants related to