public boolean isDeviceTV(Context context){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    UiModeManager uiManager=(UiModeManager)context.getSystemService(Context.UI_MODE_SERVICE);
    return uiManager != null && uiManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
  }
  return false;
}

public boolean isDeviceTV ( Context context ) { if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . LOLLIPOP ) { UiModeManager uiManager = ( UiModeManager ) context . getSystemService ( Context . UI_MODE_SERVICE ) ; return uiManager != null && uiManager . getCurrentModeType ( ) == Configuration . UI_MODE_TYPE_TELEVISION ; } return false ; }
determines if the current device is a tv .
