2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
メディアを使用したラジオの実装
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
ラジオ UI は独立したアプリとして実装されます。ラジオ UI をラジオのハードウェアと統合する方法については、ラジオの実装をご覧ください。
次のセクションでは、ラジオ UI をメディアと統合して、メディアソースとラジオを単一のアプリのように操作できるシームレスなユーザー エクスペリエンスを実現する方法について説明します。
次の図は、ラジオとメディアのリファレンス実装によってアプリ切り替えユーザーフローが実装される方法を示しています。

図 1:メディアソース切り替えユーザーフロー
メディア内の他アプリとラジオとの間でシームレスな移行を実現するため、car-media-common
ライブラリではメディアソース セレクタの起動に使用できる Android インテントが定義されています。AOSP では、このセレクタはアプリ ランチャーに実装され、アプリを起動する場合と同じ UI を表示しますが、メディアソースのみを表示するフィルタが適用されています。
OEM は、現在のアプリ ランチャーの実装をそのまま使用するか、カスタマイズしたメディアソース セレクタを実装するか、選択できます。
セレクタは 2 つのモードで動作します。
- 通常のフロー。セレクタを使用すると、選択したソースがメディアに表示され、ユーザーがコンテンツを閲覧できます。
- スイッチとして。セレクタを使用することでソースが切り替わりますが、メディアはユーザーに表示されません。これは、ホームページのセレクタ アイコンに該当します。ソースを選択すると、最後に表示されていた画面がユーザーに表示されます(この場合はホームページ)。
メディアソースの切り替えに使用するインテントは MediaSource#getSourceSelectorIntent()
メソッドから取得できます。これは、上記の各フローを起動するインテントを返す popup
ブール値を受け入れます。
実際のインテントは packages/apps/Car/libs/car-media-common/res/values/config.xml
で定義されます。この設定をカスタマイズするには、ビルド時のオーバーレイを使用します。
ラジオアプリの置き換え
ラジオアプリによってメディア ブラウズとメディア セッションが実装されていると、アプリ ランチャーにラジオが表示されます。ユーザーがアイコンをクリックしてもメディアが起動しないようにするには、2 つの要素が必要になります。ラジオが次の条件を満たしている必要があります。
- ランチャー アクティビティがある。
- カスタムソースとして宣言されている。それには、
car-media-common/res/values/config.xml
の custom_media_packages
キーにコンポーネント名を追加します。
UX の運転制限
メディアは、ドライバーの注意散漫に関する UX の制限をすべて遵守する必要があります。そのためには、メディアは CarUXRestrictionManager をリッスンし、そのポリシーをすべて実装する必要があります。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 UTC。"],[],[],null,["# Implement radio with Media\n\nThe Radio UI is implemented as an independent app. Instructions on how to integrate a\nRadio UI to the radio hardware can be found at\n[Implement radio](/docs/automotive/broadcast-radio).\n\nThe following section describes how to integrate Radio UI with Media to provide users with a\nseamless experience that enables users to interact with media sources and radio as if they were a\nsingle app.\n\nMedia source switching user flow\n--------------------------------\n\nThe following diagram illustrates how the reference implementation of Radio and Media implements\nthe app switching user flow.\n\n**Figure 1.** Media source switching user flow\n\nTo provide a seamless transition between Radio and other apps in Media, the\n`car-media-common` library defines Android intents that can be used to launch a media\nsource selector. In AOSP, this selector is implemented in the App Launcher, presenting the same UI\nfor launching apps but filtered to display only media sources.\n\nOEMs can opt to take the current App Launcher implementation as is, or implement a customized\nmedia source selector.\n\nThe selector can act in two modes:\n\n- **Normal flow.** After using the selector, the selected source is displayed in Media so the user can browse its content.\n- **As a switch.** A selector is used to switch sources, but the media is not displayed to the user. This is true of the Selector icon on the Home Page. After selecting a source, the most recent previous screen is displayed to the user (in this case, the Home page).\n\nThe intent used to switch between media sources can be obtained from the\n`MediaSource#getSourceSelectorIntent()` method, which accepts a `popup`\nBoolean that returns an intent to launch each of the flows described above.\n\nThe actual intents are defined at\n`packages/apps/Car/libs/car-media-common/res/values/config.xml`. To\ncustomize this configuration, use build-time overlays.\n\n### Replace the Radio app\n\nGiven that the Radio app implements Media Browse and Media Session, Radio is displayed\nin the App launcher. To prevent launching Media when a user clicks the icon, two elements\nare required. Radio *must*:\n\n- Have a *launcher* activity.\n- Be declared as a *custom source* . To do so, add the component name to the `custom_media_packages` key in `car-media-common/res/values/config.xml`.\n\nUX driving restrictions\n-----------------------\n\nMedia must observe all UX driving distraction restrictions. To do so, Media must listen to the\n[CarUXRestrictionManager](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictionsManager)\nand implement all its policies.\n\n- Media must connect to the [Car](https://developer.android.com/reference/android/car/Car) library and get an instance of [CarUXRestrictionManager](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictionsManager).\n- Media must subscribe to updates in the list of [CarUxRestrictions](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions) and implement them as documented.\n- Particularly important for Media are:\n - [UX_RESTRICTIONS_NO_SETUP](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions.html#UX_RESTRICTIONS_NO_SETUP). In this case, the sign-in flow must be disabled.\n - [UX_RESTRICTIONS_LIMIT_STRING_LENGTH](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions.html#UX_RESTRICTIONS_LIMIT_STRING_LENGTH). Error messages and other text provided by the media apps must be limited to the given length."]]