How to check if the application works on an Android TV

Is there a way to check if the application works on Android TV or Android Mobile?

I know how to check a running assembly. I want to start a specific service if the application runs on Android TV vs Mobile. I was hoping to place two in the same library.

+14
android android tv
source share
3 answers

Some options:

1) Request a system for the big screen

2) Use reflection to identify specific classes of TV

3) Use hasSystemFeature to detect the lack of a touch screen

Additional Information

https://developer.android.com/training/tv/start/hardware.html

And a similar answer for Google TV

Detect GoogleTV from an Android App

+3
source share

From Processing TV equipment in Android Documents:

public static final String TAG = "DeviceTypeRuntimeCheck"; UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE); if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) { Log.d(TAG, "Running on a TV Device"); } else { Log.d(TAG, "Running on a non-TV Device"); } 
+26
source share
 private boolean isDirectToTV() { return(getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION) || getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK)); } 

This will return true if the device advertises itself as having the functions android.hardware.type.television or android.software.leanback . Android TV and Fire TV do it right; I have not tried this in another environment yet.

+15
source share

All Articles