Display a Now Playing card

TV apps must display a Now Playing card when playing media behind the launcher or in the background. This card lets users return to the app that is currently playing media.

The Android framework displays a Now Playing card on the home screen when there is an active MediaSession. The card includes media metadata such as album art, title, and app icon. When the user selects the card, the system opens the app.

You can use the MediaSession class to implement the Now Playing card.

Figure 1. Display a Now Playing card when playing media in the background.

Now Playing card

After you implement a media session, set the session to active, and request audio focus, the Now Playing card appears.

Note: The Now Playing card displays only for a media session with the FLAG_HANDLES_TRANSPORT_CONTROLS flag set. This flag is deprecated on API level 26. However, this flag could still be needed on older devices for backwards compatibility.

The card is removed from the launcher screen when a setActive(false) call deactivates the media session or when another app initiates media playback. If playback is completely stopped and there is no active media, deactivate the media session immediately. If playback is paused, deactivate the media session after a delay, usually from 5 to 30 minutes.

Update the card

Whenever your app updates the playback state in the MediaSession, the Now Playing card updates to show the state of the current media. To learn how to do this, see Update the playback state.

Similarly, your app can update the MediaMetadata to provide information to the Now Playing card about the current media, such as the title, subtitle, and various icons. To learn how to do this, see Update the media metadata.

Respond to user action

When the user selects the Now Playing card, the system opens the app that owns the session. If your app provides a PendingIntent to setSessionActivity(), the system launches the activity you specify, as shown in the following code snippet. If not, the default system intent opens. The activity you specify must provide playback controls that let users pause or stop playback.


val pi: PendingIntent = Intent(context, MyActivity::class.java).let { intent ->
            context, 99 /*request code*/,


Intent intent = new Intent(context, MyActivity.class);
PendingIntent pi = PendingIntent.getActivity(context, 99 /*request code*/,
        intent, PendingIntent.FLAG_UPDATE_CURRENT);