Android Auto stuck in error state, how to dismiss?

Viewed 354

I am extending my audio streaming app to work with Android Auto, I have implemented a MediaBrowserService and all is working well. If during playback a stream returns an error, I update the MediaSession appropriately passing a state of PlaybackStateCompat.STATE_ERROR. In this case Android Auto shows the error on screen but I cannot see any way of dismissing the error. If I navigate back to my apps menu within Android Auto I can see it making requests to my Service to gather MediaItems but the error message stays on the screen.

The only way to recover is to exit Android Auto and then reopen it, the error is then gone and the MediaItems are again visible to browse and play.

Do I need to update the MediaSession somehow to remove the error state or should there be a way of dismissing the error message on screen?

For reference I am using the Android Auto app on my phone to test this.

Thanks

1 Answers

Yep, you’ll need to update the media session with a new playback state to dismiss the error instead of an action on the screen. The media session sends / receives all communication with the player, and the player is only called from the media session that controls it.

Here’s a couple of links on working with error states:

Audio Playback for Auto: Handling Errors

MediaSession States and Errors

Related