Skip to content

Most visited

Recently visited


Enabling Background Playback

This lesson teaches you to

  1. Request Background Playback

A user watching content on a TV device may decide to switch to the TV launcher at any time. If a user switches to the launcher while using a TV playback app, by default the app is paused. Since the user did not explicitly request to pause playback, the default behavior might seem abrupt and unexpected. This lesson describes how to enable background playback in your app, which provides a better user experience.

The method requestVisibleBehind() was deprecated in API level 26.
It will be removed in a future release. The functionality described on this page is not supported in Android version 8.0 and later.

Request Background Playback

Normally, when the user clicks on Home to display the TV launcher, the activity pauses. However, your app can request background playback, in which the activity continues playing behind the TV launcher.

To request background playback, call requestVisibleBehind(). Be sure to clean up media resources if the activity stops being visible. For example, you should free media resources if requestVisibleBehind() returns false to indicate that the request failed, or if the system calls your override of onVisibleBehindCanceled().

public void onPause() {
  if (mVideoView.isPlaying()) {
    // Argument equals true to notify the system that the activity
    // wishes to be visible behind other translucent activities
    if (! requestVisibleBehind(true)) {
      // App-specific method to stop playback and release resources
      // because call to requestVisibleBehind(true) failed
  } else {
    // Argument equals false because the activity is not playing

public void onVisibleBehindCanceled() {
  // App-specific method to stop playback and release resources
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields


Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (April 2018 — Developer Survey)