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.
CommonsWare
source share