Developing for the Living Room: How to Build an Android App for Fire TV (Part 5)

Providing the Details of the App Content through the DetailsFragment

Mario Viviani
Amazon Developers
Published in
3 min readDec 14, 2016

--

In Part 1 of this series we analyzed the TV Interaction Model, based on three steps: Browsing for Content, Reading Description and Details, and Playing the Content. The first action, Browsing for Content, as we have seen in Part 3 of this series, is achieved through the BrowseFragment.

Now let’s see how we can provide information about a specific piece of content, following the second step of the user journey, Reading Description and Details. To do this we’ll use one of the main components of a Leanback-enabled project: the DetailsFragment.

The DetailsFragment

This is the DetailsFragment

The DetailsFragment is displayed when the user selects a specific piece of content on the BrowseFragment. It contains information like Title, Subtitle, Description, and is accompanied by a preview of the content. It also contains Actions that we can prompt our user to perform.

One of the most important classes used in the DetailsFragment is DetailsOverViewRow. This class defines which content is displayed in the fragment (as seen in the previous episode, DetailsOverViewRow takes advantage of a Presenter, called DescriptionPresenter) and, most importantly, is responsible for defining the Actions that we can prompt our user to perform.

In the highlighted row we demonstrate how easy it is to add a specific Action to the DetailsFragment. Just by coding addAction() we can add a new Action for the user to perform. In this case we added the unique ID ACTION_WATCH_TRAILER, for the Action and two Strings Watch Trailer”, “FREEto define the text field of the button.

Once we have added this line, the Action will be displayed on the DetailsFragment.

By using Actions we can easily add IAP items like “Rent the Content”, “Buy”, or “Subscribe”. It is just a matter of attaching a Listener to the Actions to perform consequent tasks.

When we deploy a Leanback-enabled project, the only Action that is defined by default is the “Watch Trailer” that prompts the trailer of the content to play.

Stay tuned for Part 6: How to Play Video Content using the PlaybackOverlayFragment

In the next and final episode of this series we’ll show how to play the content, leverage the Remote Control, and how to show the on-screen controls using the PlaybackOverlayFragment.

Stay tuned!

Mario Viviani (@mariuxtheone)

Originally published at developer.amazon.com.

--

--