Android Auto и Android Automotive OS (AAOS) устанавливают состояние воспроизведения в STATE_ERROR и предоставляют пользователю локализованное сообщение об ошибке. Затем приложения могут отобразить это сообщение пользователю.
Для устранения ошибки необходимо указать сообщение об ошибке с помощью setErrorMessage .
See PlaybackStateCompat for a list of the error codes you can use when designing the error message to indicate the nature of the error. If a user must interact with their phone to resolve an issue, include this instruction in the error message.
Сообщения об ошибках должны быть доступны пользователю и соответствовать его языковым настройкам. Например, если контент недоступен в языковой среде пользователя, используйте ERROR_CODE_NOT_AVAILABLE_IN_REGION .
Котлин
mediaSession.setPlaybackState(
PlaybackStateCompat.Builder()
.setState(PlaybackStateCompat.STATE_ERROR)
.setErrorMessage(PlaybackStateCompat.ERROR_CODE_NOT_AVAILABLE_IN_REGION, getString(R.string.error_unsupported_region))
// ...and any other setters.
.build())
Java
mediaSession.setPlaybackState(
new PlaybackStateCompat.Builder()
.setState(PlaybackStateCompat.STATE_ERROR)
.setErrorMessage(PlaybackStateCompat.ERROR_CODE_NOT_AVAILABLE_IN_REGION, getString(R.string.error_unsupported_region))
// ...and any other setters.
.build())
To learn more about error states, see Using a media session: States and errors .