# 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: [Stories by Danny Preussler on Medium](<https://devfeed.tech/sources/stories-by-danny-preussler-on-medium.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [App](<https://devfeed.tech/topics/app.md>), [Code](<https://devfeed.tech/topics/code.md>), [Query (disambiguation)](<https://devfeed.tech/topics/query.md>), [Google](<https://devfeed.tech/topics/google.md>)

Tags: [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>), [apps](<https://devfeed.tech/tags/apps.md>), [audio](<https://devfeed.tech/tags/audio.md>), [callback](<https://devfeed.tech/tags/callback.md>), [car](<https://devfeed.tech/tags/car.md>), [code](<https://devfeed.tech/tags/code.md>), [google](<https://devfeed.tech/tags/google.md>), [google-assistant](<https://devfeed.tech/tags/google-assistant.md>), [integration](<https://devfeed.tech/tags/integration.md>), [manifest](<https://devfeed.tech/tags/manifest.md>), [voice](<https://devfeed.tech/tags/voice.md>)

## AI overview

This article explains how Android Auto voice searches are delivered to a music app such as SoundCloud. It compares the documented use of MediaStore.EXTRA_MEDIA_FOCUS with observed behavior, reporting that Assistant currently returns a focus value that is not defined as an SDK constant.

## 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