Search code examples
androidandroid-tv

Difference between PreviewChannel & Channel?


What is the difference between PreviewChannel & Channel in TV Provider library?


Solution

  • A Channel refers to a content row in the experience that launched on Android TV starting in Android 8*. A PreviewChannel is specifically a row that an app adds to display its own content (could be top content or most recent content or whatever is appropriate for that app). You can think of a PreviewChannel as a type of Channel but it's not a subclass from the code perspective. There are other channel types such as the Watch Next channel (labeled as "Play Next" or "Continue Watching" depending on the launcher). OEMs can also create their own channels. Typically Channel is only used to query explicit data that isn't relevant to a preview channel such as the network affiliation or whether a channel is searchable. An app developer will rarely use the Channel class.

    If you want to create a channel that previews content from your app, then you want to use PreviewChannel.Builder to create the channel and PreviewProgram.Builder to create the tiles (programs) that you want to display in it. If you're creating only one preview channel, Android TV allows you to display it without user interaction and you can use PreviewChannelHelper.publishDefaultChannel() to display it.

    If you want to display content the user has recently been watching (for example, the user watched half of a movie or the user finished episode 1 and you want to display episode 2), then you can use the Watch Next channel. There is only one Watch Next channel and it's owned by the system. You can create programs for this with the WatchNextProgram.Builder and publish them with PreviewChannelHelper.publishWatchNextProgram().

    For more detailed implementation info including updating and deleting, you can see the Reference App source code, which implements both a preview channel and updates to watch next.

    *I added an Asterisk because this experience is changing over time. Many newer devices have the Google TV experience but even some that don't have it are getting updated to an experience that includes tabs for separate sections within the launcher. These experiences display watch next prominently but often don't display preview channels.