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.

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.

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. It is recommended to use Theme. Leanback to establish a consistent visual style for TV apps. Don’t use title bars for TV apps. It is a standard UI element for Android apps on phones and tablets. The text and controls in a TV app’s layout should be easily visible and navigable from a distance: Avoid lightweight fonts. Avoid fonts that have very narrow or very broad strokes. Use light text on dark backgrounds. Break text into small chunks. Follow these basic rules to keep your layouts effective on large screens: Activities must support the landscape orientation or your app will not appear to Android TV users in the Google Play store. Put on-screen navigation controls on the left or right side of the screen and save the vertical space for content. Add sufficient margins between layout controls to avoid a cluttered UI. Create UIs that are divided into sections using Fragments. 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. 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. Avoid layout AntiPatterns 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