Implement radio with Media

The Radio UI is implemented as an independent app. Instructions on how to integrate a Radio UI to the radio hardware can be found at Implement radio.

The following section describes how to integrate Radio UI with Media to provide users with a seamless experience that enables users to interact with media sources and radio as if they were a single app.

Media source switching user flow

The following diagram illustrates how the reference implementation of Radio and Media implements the app switching user flow.

Media source switching user flow

Figure 1. Media source switching user flow

To provide a seamless transition between Radio and other apps in Media, the car-media-common library defines Android intents that can be used to launch a media source selector. In AOSP, this selector is implemented in the App Launcher, presenting the same UI for launching apps but filtered to display only media sources.

OEMs can opt to take the current App Launcher implementation as is, or implement a customized media source selector.

The selector can act in two modes:

  • Normal flow. After using the selector, the selected source is displayed in Media so the user can browse its content.
  • 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).

The intent used to switch between media sources can be obtained from the MediaSource#getSourceSelectorIntent() method, which accepts a popup Boolean that returns an intent to launch each of the flows described above.

The actual intents are defined at packages/apps/Car/libs/car-media-common/res/values/config.xml. To customize this configuration, use build-time overlays.

Replace the Radio app

Given that the Radio app implements Media Browse and Media Session, Radio is displayed in the App launcher. To prevent launching Media when a user clicks the icon, two elements are required. Radio must:

  • Have a launcher activity.
  • 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.

UX driving restrictions

Media must observe all UX driving distraction restrictions. To do so, Media must listen to the CarUXRestrictionManager and implement all its policies.