Developer Console

Step 2: Understand the Anatomy of a Leanback-Enabled Android App for Amazon Fire TV (Fire TV)

Let's understand why these four libraries — leanback, recyclerView, appCompat, and Glide — are important in a Leanback-enabled project.

New Libraries in Project Dependencies

Once you have created a new TV project using the Android Studio Wizard, you may notice that the wizard has automatically included some libraries in your project dependencies.

Your build.gradle file will look like this:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile ''
    compile ''
    compile ''
    compile 'com.github.bumptech.glide:glide:3.4.+'

Let's understand why each one of these libraries is important in a Leanback-enabled project:

  • Leanback: The v17 Leanback Support Library is a standard Android support library focused on providing APIs and widgets to simplify the development of TV apps. Most of the components used in a Leanback-enabled project are contained in this library.
  • RecyclerView: This library provides the RecyclerView class. This class is used to display large datasets efficiently recycling views, improving performance, and saving memory. A lot of the components of the Leanback Library rely on RecyclerView. The RecyclerView implements a very common programming pattern in Android, which is the Viewholder pattern. This is important to master when developing for TV (more info on ViewHolder here.
  • AppCompat: The main purpose of the AppCompat library is to provide APIs, widgets, and tools across multiple versions of Android. It's useful to provide your Android application on multiple devices, in particular if you ship your app in a single .apk binary file both for handheld devices and for TV.
  • Glide: This is an efficient open source media management and image loading framework for Android. It allows you to efficiently decode, download, and apply images from the cloud. It's used by some components of the Leanback-enabled app to efficiently fetch thumbnails and images to display previews of the content in the TV app.

All these components are the main building blocks to create a solid and consistent TV experience for users.

The Main Streaming App Interaction Model

The user journey when using a media streaming app is comprised of three main steps:

The user journey when using a media streaming app.
  1. Browse for content: Users go through the main catalog of media, searching for interesting content to play.
  2. Read description and details: When an item has caught users' interest, they will focus on reading the descriptions and details of the content in order to make a decision.
  3. Play: When the users have found something to watch, they will start playing the content.

The Main Components of a Leanback-Enabled Android App

A Leanback-enabled Android app follows this interaction model. In fact, the three main components of a Leanback-enabled app are the same three main steps of the media streaming app interaction model:

The three main components of a Leanback-enabled app.
  1. BrowseFragment: Allows you to browse for content in the main app catalog.
  2. DetailsFragment: Grants access to extended details for specific content selected in the BrowseFragment and to perform actions like "Play Content."
  3. PlaybackOverlayFragment: This fragment allows you to overlay media controls on a full-screen media player.

This 1:1 mapping with the media streaming app interaction model provides developers a consistent project structure, simplifying the app design and development process.

Using a well-defined app structure like the one provided by the Leanback approach also creates easier onboarding process, since there is a high chance that users will have already been interacting with media streaming apps built following the same pattern.

Next Steps

Continue on to the next step: Step 3: Browse the Content of a Leanback-Enabled Android App.

Last updated: Oct 29, 2020