Leanback Library in Android:

Shubham
4 min readApr 4, 2023

--

Source: Google

Introduction:

Android TV platform is built only for televisions and it is way more updated than traditional televisions, and development of Android TV apps requires different approach than traditional android development. Because if we see in mobile apps we use user touch to navigate different screen or for performing different operations, but in case of televisions we have to navigate through remote control. And then the concept of Leanback Library comes into existence.

In this blog we will discuss about the leanback library and what things should be consider while implementing this library for developing the Android TV applications.

Overview of Leanback

Leanback library is introduced by Google to make a framework for big screen on top of android framework which provides the set of UI components which makes easy development for developer.

We watch television by siting at some distance from screen, we lean back to watch television and hence the name of this library, Leanback library.

As we are having the remove to navigate through different screens or to perform different operations, leanback is designed in such a way that user can do such operations using remote buttons. Leanback provides different views those are good looking on big screens and easy to operate from remote control, like grid view, list view, vertical grid view. There are different fragments which we can use for different purposes. Leanback provides the different components and it is a feature rich library which is easy for developer and for user as well.

Features of Leanback Library:

Leanback is feature rich library for developing the TV app, here are some key features of leanback library:

  1. UI Components: Leanback library provides different build-in UI components from which you can start your development.
  2. Navigation: Navigation is handled properly, in which we can navigate through different components or through different screens.
  3. TV Input: We can use different TV input using this library, like game pad, dpad navigation, voice search.
  4. Playback Support: It supports for playback components like audio/video.
  5. Customization: You can customize leanback library according to your requirement.

How TV app is different from Mobile app.

You can build an app for mobile, tablet, watch or for TV as well. There are key things that you have to look to build an app for android TV.

First you have to declare that you don’t have to use touch screen, and that you have to declare in manifest file, this declaration is required to consider an app for android TV play store and needed to make an android TV app.

Second you have to declare that you are using leanback interface. If you set this feature value as true then your app will only work for devices which supports leanback, you can set this as false as well if you are building an app for mobile and TV both.

Third is declaring an activity, you have to declare leanback launching activity while defining the activity, you have to set intent filter as LEANBACK_LAUNCHER. If you are building the app for mobile and TV both then you have to keep 2 different launching activity, and for mobile’s launching activity you have to set intent filter as LAUNCHER.

for TV activity
for Mobile activity

Now forth is you have to provide an banner for your app when you set it as leanback supported. This banner is visible on Home screen of your TV on app list row.

Different Fragments in Leanback Library:

Leanback library provides a different kinds of fragments for different purposes, we can customize these fragments according to our requirement, some of the fragments are mentioned below:

  1. RowSupportFragment:
  2. ErrorFragment:
  3. SearchFragment:
  4. DetailsFragment:
  5. PlaybackFragment:
  6. HeaderFragment:
  7. GuidedStepFragment:
  8. BrowseFragment:

Presenters:

Presenter is the key component of MVP design pattern, these are mediator between data model and user interface.

  1. CardPresenter
  2. RowPresenter
  3. PresenterSelector
  4. AbstractDetailsDescriptionPresenter
  5. PlaybackControlsPresenter
  6. FullWidthDetailsOverviewRowPresenter

Final Words:

I hope you have get an idea about Leanback library, its feature and things that should consider while developing the app for TV.

--

--

Shubham
Shubham

Written by Shubham

Blogger | Android Developer | Android & Fire TV developer

No responses yet