如何用代码区分android TV和手机? 适配Android TV ?

可通过以下方法判断是否运行在TV设备上
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")
}

猜你喜欢

转载自blog.csdn.net/weixin_42493749/article/details/81744554