In the previous article we got an overview of Google TV and some of the features which offer developers the potential to create some interesting apps. In this article we’ll look at some of the differences between developing for Google TV compared to the Android phone and tablet devices that we’ve become used to.
From a development perspective there is really not much difference. It’s Android 3.2 (at the time of writing) but the big difference is the input mechanism. The vast majority of Android devices have touch screens, whereas Google TV relies largely on a direction keys and an enter / fire key configured in a direction pad (D-pad).
Android has always supported different input mechanisms as the very first commercially available Android phone (the G1) demonstrated. It had a trackball and it was possible to use the device entirely using the trackball, with the exception of any third party apps which did not include the minor additions to properly support non-touchscreen input methods. Developers can be forgiven for concentrating solely on touch-based UIs because of the ubiquity of touchscreens on phone and tablet devices.
One key thing to remember is that, by default, Android apps are assumed to target touchscreen devices. If you are developing for Google TV you must explicitly declare in your manifest that a touchscreen is not required:[xml]
This is fine if your APK targets both TV and touchscreen devices, but if you want to limit the availability of your APK to TV devices in Play Store you should include the following as well:[xml]
I specifically mentioned APK rather than the “app” here because it is possible to publish multiple APKs targeting different device characteristics as a single app on Play Store. What you include in the manifest helps determine which APK is provided to different devices.
In terms of layouts we specifically need to design only for landscape orientation and the Android screen size of “large”. Google advise designing for 1080p and allowing the OS to downsize to 720p rather than the other way round. The is no reason why you can’t do both, but the OS downsizing should work fairly well as 1080p and 720p are both 16:9 aspect ratios.
It is worth remembering that Google TV devices do not contain the same hardware features as your average phone or tablet. Obviously there is no telephony support but there are no motion / orientation sensors, camera, GPS, or Bluetooth. Despite there being no GPS, there is a simple LocationProvider implementation which returns a static location based upon the postal / ZIP code entered during the device setup process.
If you are developing a single APK to run on both Google TV, phone, and / or tablet devices it is relatively easy to detect which hardware is available and simply enable sections of the app that are dependent on that hardware being available using boolean logic. For example, if your app has the ability to capture a photograph from the camera on a phone or tablet, you can detect whether a camera is available:[java] PackageManager pm = getPackageManager();
if(pm.hasSystemFeature( PackageManager.FEATURE_CAMERA )
// Enable camera button in UI
When this runs on a Google TV device, the camera button will not be shown. This is, of course, assuming that manufacturers do not create Google TV devices with cameras in them. However, even if they do, using this technique will ensure that if the app is run on a Google TV device with a camera, then the relevant feature will be enabled at runtime.
Another thing that we can use is Android’s resource management to allow us to use different layouts. If we add a Google-TV specific layout to
res/layout-dpad, or even
res/layout-land-notouch-dpad this will be selected automatically at runtime.
In the concluding part of this series we’ll have a look at some UI / UX considerations that we need to take in to account when creating apps for Google TV.
© 2012, Mark Allison. All rights reserved.
Copyright © 2012 Styling Android. All Rights Reserved.
Information about how to reuse or republish this work may be available at http://blog.stylingandroid.com/license-information.