Support fake Android TV devices

Android TV is included in some modern Smart TVs, and there are also external set-top-boxes to get Android TV for any TV with HDMI input.

However, there are also some set-top-boxes which almost, but not quite, support Android TV.

With not so much extra effort, it is possible to make an Android app supporting those fake Android TV devices as well as the real ones.

In addition to the guidelines from Google for building Android TV apps, do this to support the fake TV Android TV devices as well:

  1. If you build an app for both Android TV and mobile (smartphone/tablet), make sure to build a separate .apk for Android TV, using Gradle flavors. (This is a good idea anyway since it will keep down the .apk size.)
  2. Do not use the television resource qualifier, put TV resources in unqualified resource directories instead. (When building a separate .apk for TV only, this resource qualifier is not necessary.)
  3. Specify both android.intent.category.LAUNCHER and android.intent.category.LEANBACK_LAUNCHER in the intent-filter for the launcher activity in the app manifest.:
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
        <category android:name="android.intent.category.LAUNCHER" />
  4. Specify Leanback support with required=false in the app manifest:
        android:required="false" />
  5. Specify both android:icon and android:banner in the app manifest:
  6. If you use the Leanback SearchFragment, you need to disable voice search on the fake devices, since they usually does not support speech recognition:
        static boolean isRealAndroidTvDevice(Context context) {
            UiModeManager uiModeManager = (UiModeManager) context.getSystemService(UI_MODE_SERVICE);
            return (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION);
        if (!isRealAndroidTvDevice(context)) {
            setSpeechRecognitionCallback(new SpeechRecognitionCallback() {
                public void recognizeSpeech() {
                    // do nothing
  7. The fake Android TV devices usually get the display pixel density wrong. You can programatically fix this in onCreate on the launcher activity:
        if (!isRealAndroidTvDevice(context)) {
            DisplayMetrics metrics = new DisplayMetrics();
            metrics.density = 2.0f;
            metrics.densityDpi = 320;
            metrics.scaledDensity = 2.0f;
This entry was posted in Android. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

(this is a captcha)