Tv Support to an already existing Android App

Posted By : Shifali Rai | 27-Dec-2018

Adding Tv support to Android app gives user immense comfort and opportunities as the apps are customized to run on a large screen and can be accessed while sitting on a couch.TV apps use the same interface and programming structure as of phones so one can provide Tv support to their already existing app.


Prerequisites :

  1.  Tv Launcher Activity: An app intended to run on Tv must define an activity inside manifest. 
  2.  Tv Support Libraries: Tv support libraries are optional. They provide special widgets for Tv interface.


Declare Tv activity 

Tv launcher activity must be defined in your apps manifest using CATEGORY_LEANBACK_LAUNCHER inside the intent filter.The following code piece shows a way to embody this intent filter :

<activity android:name=".ui.activity.SplashActivityTv"
            android:screenOrientation="landscape" >
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LEANBACK_LAUNCHER" />


 Leanback Support 

Add the following code inside your manifest tag in app manifest:

    <uses-feature android:name=""
        android:required="false" />


Manage Tv Device 

If the user wants the interface to work differently on phone and Tv one can check for the device on which the app is running. Below code piece shows a way to do so:

UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
        if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
            Log.d(TAGG, "Running on a TV Device");
        } else {
            Log.d(TAGG, "Running on a non-TV Device");


Tv Layouts

Tv layouts should follow some basic guidelines to have an effective appearance.Follow the below tips :

  • Build layouts in landscape mode.
  • Create UIs using Fragments and views such as GridView to utilize all the horizontal space.
  • Use View groups such as LinearLayout or Relative Layout.


Accessing Tv Buttons

One can access  Tv buttons and to perform some customized actions on it. Below is an example of performing an action on  a key :

public boolean onKeyDown(int keyCode, KeyEvent event) {

    switch (keyCode) {
        case KeyEvent.KEYCODE_A:
            //your Action code
            return true;
    return super.onKeyDown(keyCode, event);



This blog helps in providing basic TV support to your Android app. For more on Tv support follow the links below :

Request for Proposal

Recaptcha is required.

Sending message..