Android Auto と Android Automotive(AAOS)は、再生状態を STATE_ERROR
に設定し、ユーザー向けのローカライズされたエラー メッセージを提供します。アプリは、ユーザーにメッセージを表示できます。
エラーに対処するには、setErrorMessage
を含むエラー メッセージを指定します。
エラーの内容を示すエラー メッセージを設計する際に使用できるエラーコードの一覧については、PlaybackStateCompat
をご覧ください。問題を解決するためにお客様がスマートフォンを操作する必要がある場合は、エラー メッセージにその手順を含めます。
エラー メッセージはユーザー向けであり、ユーザーのロケールを対象とする必要があります。たとえば、ユーザーのロケールでコンテンツを利用できない場合は、ERROR_CODE_NOT_AVAILABLE_IN_REGION
を使用します。
Kotlin
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())
エラー状態の詳細については、メディア セッションの使用: 状態とエラーをご覧ください。