A quick tour around Android platforms #1: Android TV

This article is the first part of a tour around the Android platforms: Android TV, Wearable
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.
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
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
Declare a TV Activity
Let’s go to the Manifest file. Your app must declare a launcher activity with a specific intent filter.
<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 is a support library for TV user interfaces that
Touchscreen is not required
If you want
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
- 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.
- 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