Hardware Features on TV

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.

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 uses-feature guide.

Unsupported Hardware Features

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:

Hardware Android feature descriptor
Camera android.hardware.camera
GPS android.hardware.location.gps
Microphone android.hardware.microphone
Near Field Communications (NFC) android.hardware.nfc
Telephony android.hardware.telephony
Touchscreen android.hardware.touchscreen

Checking Available Features

To check if a feature is available at runtime, call hasSystemFeature(String). This method takes a single string argument that specifies the feature you want to check. For example, to check for a touch screen, use hasSystemFeature(String) with the argument FEATURE_TOUCHSCREEN.

The following code example demonstrates how to detect the availability of a hardware features at runtime:

// 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!");
}

Note: You can also use the UiModeManager.getCurrentModeType() method to detect the current platform type. For TV devices, this method returns a value of Configuration.UI_MODE_TYPE_TELEVISION.

Handling Unsupported Features

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 features.

Touch screen

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.

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 Navigation for TV.

You can explicitly declare if your application requires (or does not require) a touch screen by including the following entry in your manifest:

<uses-feature android:name="android.hardware.touchscreen"
        android:required="false"/>

Camera

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:

<uses-feature android:name="android.hardware.camera" android:required="false" />

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:

// Check if the camera hardware feature is available.
if (getPackageManager().hasSystemFeature("android.hardware.camera")) {
    Log.d("Camera test", "Camera available!");
} else {
    Log.d("Camera test", "No camera available. View and edit features only.");
}

GPS

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.

LocationManager locationManager = (LocationManager) this.getSystemService(
        Context.LOCATION_SERVICE);
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);
}