blob: ddec49688ff97360a306afdc7be2fa773ddeaf2d [file] [log] [blame]
page.title=Hardware Features on TV
<div id="qv-wrapper">
<div id="qv">
<h2>In this document</h2>
<li><a href="#unsupported-features">Unsupported Hardware Features</a></li>
<li><a href="#workaround-features">Handling Unsupported Features</a></li>
<li><a href="#check-features">Checking Available Features</a>
<li><a href="#no-touchscreen">Touch screen</a></li>
<li><a href="#no-camera">Camera</a></li>
<li><a href="#no-gps">GPS</a></li>
<p>TVs do not have some of the hardware features found on other Android devices.
Touch screens, cameras, and GPS receivers are some of the most commonly used hardware features
which are typically not available on a TV. When you build an app for TV, you must carefully
consider if your app can handle not having these features and, if necessary, work around them.</p>
<p>This guide discusses the hardware features not available on TV devices and shows you how to
work around those limitations in your app. For more information on filtering and declaring
features in the manifest, see the
<a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">uses-feature</a> guide.</p>
<h2 id="unsupported-features">Unsupported Hardware Features</h2>
<p>TVs have a different purpose from other devices, and so they do not have hardware
features that other Android-powered devices often have. For this reason, the Android system
does not support the following features for a TV device:
<th>Android feature descriptor</th>
<td>Near Field Communications (NFC)</td>
<h2 id="check-features">Checking Available Features</h2>
<p>To check if a feature is available at runtime, call {@link}. This method takes a single string
argument that specifies the feature you want to check. For example, to check for a touch screen,
use {@link} with the argument
<p>The following code example demonstrates how to detect the availability of a hardware features
at runtime:</p>
// Check if the telephony hardware feature is available.
if (getPackageManager().hasSystemFeature("android.hardware.telephony")) {
Log.d("Mobile Test", "Running on phone");
// Check if android.hardware.touchscreen feature is available.
} else if (getPackageManager().hasSystemFeature("android.hardware.touchscreen")) {
Log.d("Tablet Test", "Running on devices that don't support telephony but "+
"do have a touch screen.");
} else {
Log.d("TV Test", "Running on a TV!");
<p class="note">
<strong>Note:</strong> You can also use the {@link
UiModeManager.getCurrentModeType()} method to detect the current platform type. For TV devices,
this method returns a value of {@link android.content.res.Configuration#UI_MODE_TYPE_TELEVISION
<h2 id="workaround-features">Handling Unsupported Features</h2>
<p>Depending on the design and functionality of your app, you may be able to work around certain
hardware features being unavailable. This section discusses how to work around specific hardware
<h3 id="no-touchscreen">Touch screen</h3>
<p>Android doesn't support touch screen interaction for TV devices, since most TVs don't have touch
screens, and using a touch screen is not consistent with a viewing environment where the user is
seated 10 feet away from the display.</p>
<p>On TV devices, you should work around this limitation by supporting navigation using a directional
pad (D-pad) on TV remote control. For more information on properly supporting navigation using
TV-friendly controls, see <a href="{@docRoot}preview/tv/ui/navigation.html">Navigation for
<p>You can explicitly declare if your application requires (or does not require) a touch screen
by including the following entry in your manifest:</p>
&lt;uses-feature android:name="android.hardware.touchscreen"
<h3 id="no-camera">Camera</h3>
<p>Although a TV typically does not have a camera, you can still provide a photography-related
application on a TV. For example, if you have an app that takes, views and edits photos, you can
disable its picture-taking functionality for TVs and still allow users to view and even edit
photos. If you decide that you want to enable your camera-related application to work on a
TV device without a camera, you can add an attribute to your app manifest declaring that
a camera is not required by your app:</p>
&lt;uses-feature android:name="" android:required="false" /&gt;
<p>If you enable your application to run without a camera, you should add code to your application
that detects if the camera feature is available and makes adjustments to the operation of your app.
The following code example demonstrates how to detect the presence of a camera:</p>
// Check if the camera hardware feature is available.
if (getPackageManager().hasSystemFeature("")) {
Log.d("Camera test", "Camera available!");
} else {
Log.d("Camera test", "No camera available. View and edit features only.");
<h3 id="no-gps">GPS</h3>
<p>TVs are stationary, indoor devices, and do not have built-in global positioning system (GPS)
receivers. If your application uses location information, you can still allow users to search
for a location, or use a static location provider such as a zip code configured during the
TV device setup.</p>
LocationManager locationManager = (LocationManager) this.getSystemService(
Location location = locationManager.getLastKnownLocation("static");
Geocoder geocoder = new Geocoder(this);
Address address = null;
try {
address = geocoder.getFromLocation(location.getLatitude(),
location.getLongitude(), 1).get(0);
Log.d("Zip code", address.getPostalCode());
} catch (IOException e) {
Log.e(TAG, "Geocoder error", e);