A quick tour around Android platforms #1: Android TV

Photo of Michał Rusnarczyk

Michał Rusnarczyk

Feb 13, 2018 • 11 min read
ajeet-mestry-429216-555123-edited

This article is the first part of a tour around the Android platforms: Android TV, Wearable and Auto. We wrote down the crucial things that you should know before you get into building apps.

We will not show you how to build applications for these particular platforms step by step, but you can find more resources which will help you do so on the Android Developer site. What we want to do here is show you the minimum requirements and restrictions you must know before you start. Hopefully this will help you build an efficient and effective application.

Android TV

Let’s get started with Android TV, a platform that was introduced at Google I/O in 2014. Android TV brings new capabilities to the big screen - it allows you to run Android apps and games directly on your TV devices. TV apps use the same structure as those for phones and tablets. You can simply modify an existing Android project to support Android TV. So let’s do that.

Caution: Google recommends having a single app that supports both mobile devices and TV devices. If you need seperate apps for mobile and TV, you can publish multiple apks. More: Multiple APK Support.

Working with existing code

There are a couple of things to do before you get started. First, update the target API level to 21 (Android 5.0) and ensure that your Android build tool version is at least at version 24.0.0. Make sure that you sync gradle. Now we are ready to set up your existing code.

Declare a TV Activity

Let’s go to the Manifest file. Your app must declare a launcher activity with a specific intent filter. Otherwise the application will not be visible to users on the TV device. This additional declaration of TV activity lets Google Play identify your app as TV-compatible. Google recommends not to use the same activity layout for TV and mobile devices.

<application
  android:banner="@drawable/banner" >
  ...
  <activity
    android:name="com.example.android.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity
    android:name="com.example.android.TvActivity"
    android:label="@string/app_name"
    android:theme="@style/Theme.Leanback">
    <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
    </intent-filter>
  </activity>
</application>

Caution: If an application includes a Leanback launcher intent filter, it must provide a home screen banner image. The banner is the app launcher icon on Android TV.

Declare leanback support

Android TV apps require a declaration of leanback support in the AndroidManifest file. If your app is available for mobile (tablet, phones, wearable etc.) as well as Android TV, you have to set the required attribute value to false for the android.software.leanback declaration.

Leanback is a support library for TV user interfaces that provides a framework of classes for creating an efficient and familiar interface for TV apps as well as allows you to employ a model-view presenter approach to building applications. The classes are designed to be extended and customized.

Touchscreen is not required

If you want run your mobile application on TV devices that do not use touch screens, you must include the android.hardware.touchscreen declaration and set the required attribute value to false. This will cause your app to be recognized as a TV app. If you do not perform this step, your app will not appear in Google Play on TV devices.

Creating a project from scratch

If you are creating an Android TV application from scratch, you can skip the steps below. Android Studio will generate all the required components for you! Ignore the Working with existing code section and move straight to the Support TV hardware features section.

Support TV hardware features

TV devices are different from other Android devices. You must be aware that such features as GPS, camera and even touch screen are not available on Android TV. If you modify your application which uses a specific feature, mark all these features as required=“false” in your Manifest file. Remember that some features have subfeatures that you must specify in your app, too. Please refer to the list of unsupported TV features for more details.

If you are not sure which features are available on your device, you can check it at runtime using hasSystemFeature(String).

Remember that the following permissions imply hardware features that Android TV does not support:

  • RECORD_AUDIO
  • CAMERA
  • ACCESS_COARSE_LOCATION
  • ACCESS_FINE_LOCATION

Do not forget to mark these features as required=“false” in your Manifest file!

User navigation

TV devices use an external controller for interacting with app. This means that users navigate with controls on a remote device, using either a directional pad or arrow keys. Therefore, your app must have support for a D-pad controller. Keep in mind that this type of movement is limited to up, down left and right. Follow these steps to test if your navigation works well:

  • The user should be able navigate to all controls visible on the screen using a D-pad.
  • Make sure that D-pad up and down keys allow the user to scroll the list and that the Enter key selects an item in the list.
  • Switching between views must be predictable.

See more.

Requirements and implementation details about layouts

The most relevant usability requirements and best practices that we highlight are listed below. Your app must adhere to all of them in order to be qualified as a TV app. For more detailed information check out the official Android Developers website.

  1. If you are modifying an existing app for use on TV, your app should not use the same activity layout for TV that it does for phones and tablets.
  2. It is recommended to use Theme.Leanback to establish a consistent visual style for TV apps.
  3. Don’t use title bars for TV apps. It is a standard UI element for Android apps on phones and tablets.
  4. The text and controls in a TV app’s layout should be easily visible and navigable from a distance:
    1. Avoid lightweight fonts.
    2. Avoid fonts that have very narrow or very broad strokes.
    3. Use light text on dark backgrounds.
    4. Break text into small chunks.
  5. Follow these basic rules to keep your layouts effective on large screens:
    1. Activities must support the landscape orientation or your app will not appear to Android TV users in the Google Play store.
    2. Put on-screen navigation controls on the left or right side of the screen and save the vertical space for content.
    3. Add sufficient margins between layout controls to avoid a cluttered UI.
    4. Create UIs that are divided into sections using Fragments.
    5. To ensure there's never any blank space around the edges of your screen, TVs can clip the edges of content in a process known as overscan. Since you do not want to lose any important content to overscan, you should leave a margin around the edges of your app that's free from any user interface elements.
  6. Your TV layout should target a screen size of 1920 x 1080 pixels, and then allow the Android system to downscale your layout elements to 720p.
  7. Avoid layout AntiPatterns
  8. Follow this design guide.

TL;DR

Building an Android TV apps is not difficult if you have experience with Android Mobile. Follow the requirements and implementation details regarding layouts and design guidelines.

See also

- Part 2 about Android Wear

- Part 3 about Android Auto

Reference:

  1. Getting Started with TV Apps.
  2. TV components, UI, etc.
  3. How to use the Leanback.
  4. Handling TV hardware.
  5. Android TV build layouts.
  6. Android TV basic rules for layouts.
  7. Overscan.
  8. Creating TV Navigation.
  9. Android TV guidelines.
Photo of Michał Rusnarczyk

More posts by this author

Michał Rusnarczyk

Michal is in love with programming. But mobile app development is his true love. He has tried many...
How to build products fast?  We've just answered the question in our Digital Acceleration Editorial  Sign up to get access

We're Netguru!

At Netguru we specialize in designing, building, shipping and scaling beautiful, usable products with blazing-fast efficiency
Let's talk business!

Trusted by:

  • Vector-5
  • Babbel logo
  • Merc logo
  • Ikea logo
  • Volkswagen logo
  • UBS_Home