Build Android TV App

Posted By : Ashwini Kumar Gupta | 13-Jan-2021

Android has apps that are optimized for running on large screen devices like high-definition TVs and deliver a rich user experience. We call these large screen devices Smart TVs and the apps running on them facilitate a range of opportunities to delight users.  From content recommendations to the use of a leanback library that provides APIs to build a great user experience for remote control, users can get all.

 

TV apps use the same structure similar to phones and tablets. Hence it becomes easy for developers to either develop a fresh Smart TV app or extend the capability of the existing apps to run on Smart TVs. The only difference is the user interaction model. So, to make a successful TV app, the layout must be neat and clean so that users can understand it from a 10-feet distance. Also, the navigational controls must be handy that can work with a directional pad and select button.

 

Let's Start Implementation to build a TV App

 

Set up a TV project

 
Here we will discuss modifying an existing app to run on TV or create a new app altogether. In the case of an existing Android app, you can add Android TV support to unlock the method to design a UI for TV in your existing app architecture.

Following are the key components in creating an app that runs on TV:

 

  • Activity for TV (Required) - You must declare an activity in your application manifest that is intended to run on TV devices.
  • TV Libraries (Optional) - A number of androidx libraries are available for TV devices. They have a collection of widgets for building interactive user interfaces.

 

 

Prerequisites

 

You will require  "SDK tools to version 24.0.0 or higherand  "SDK with Android 5.0 (API 21) or higher" before getting started.

Also, to access new APIs for TV devices, create a project, or modify an existing one targeting Android 5.0 (API level 21) or higher.

 

Declare a TV Activity

 

An application must declare a launcher activity for TV in its manifest if it intends to run on TV. It uses a CATEGORY_LEANBACK_LAUNCHER intent filter to do this. The filter recognizes your app as being enabled for TV. Also, it enables Google Play to identify the app as a TV app. Once the user chooses your app on their TV home screen, the intent signals for the launch of an activity.


The Following snippet is for your Manifest-

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.demotvapp">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:banner="@drawable/app_icon_your_company"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity2"
            android:label="@string/title_activity_main2"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MainActivity"
            android:banner="@drawable/app_icon_your_company"
            android:icon="@drawable/app_icon_your_company"
            android:label="@string/app_name"
            android:logo="@drawable/app_icon_your_company"
            android:screenOrientation="landscape">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".DetailsActivity"
            android:screenOrientation="landscape" />
        <activity
            android:name=".PlaybackActivity"
            android:screenOrientation="landscape" />
        <activity
            android:name=".BrowseErrorActivity"
            android:screenOrientation="landscape" />
    </application>

    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="false" />
    <uses-feature
        android:name="android.software.leanback"
        android:required="true" />

    <uses-permission android:name="android.permission.INTERNET" />

</manifest>

 

Declare Leanback support

 

This is an important step wherein you declare that your app uses the Leanback UI which the Android TV requires. Also, set the required attribute value to false, if you are developing an app that runs on mobile (phones, wearables, tablets, etc.) as well as Android TV. In case you set the required attribute value to true, the app will run only on devices that use the Leanback UI.

<manifest>
    <uses-feature android:name="android.software.leanback"
        android:required="false" />
    ...
</manifest>

 

Also Read: Build successful Smart TV Apps With an extensive testing 

 

Declare touchscreen not required

 

TV applications do not rely on touch screens for input. So, you must clarify it in your application's manifest using the following: android.hardware.touchscreen feature is not required. The setting helps to identify your app as being able to work on a TV device. It is essential for your app to be considered a TV app in Google Play. The following code example shows how to include this manifest declaration:

<manifest>
    <uses-feature android:name="android.hardware.touchscreen"
              android:required="false" />
    ...
</manifest>

 

Also Read: Augmented Reality In Android

 

Change the launcher color 

 

There is an animation on the display screen that resembles an expanding, filled circle when a TV is being launched. You can customize the color of this animation by using the following command. Set the android:colorPrimary attribute of your TV app or activity to a specific color. Also, set the two additional transition overlap attributes to true, as shown below, from a theme resource XML file:

<resources>
    <style ... >
      <item name="android:colorPrimary">@color/primary</item>
      <item name="android:windowAllowReturnTransitionOverlap">true</item>
      <item name="android:windowAllowEnterTransitionOverlap">true</item>
    </style>
</resources>

 

That's basic for building a TV app. Hope you will enjoy building one!!!. 

 

Also Read: Understanding All About OTT App Development

 

Choose Oodles For Developing Your Next OTT or Smart TV Application

 

 

If you are looking to launch an OTT application, hire our professional OTT application development services. We are a 360-degree OTT app development company with more than 11 years of experience in building highly scalable video streaming platforms. Book a free consultation with us here.

About Author

Author Image
Ashwini Kumar Gupta

.He is the Lead Mobile Application Developer. Works on React Native and Native Android technology.

Request for Proposal

Name is required

Comment is required

Sending message..