简体   繁体   English

如何确定Android设备是否有屏幕,即它是否是Android机顶盒?

[英]How to determine if an Android device has a screen i.e. whether it is an Android set top box?

I know one can obtain screen sizes, but I would like to know if someone has ever been able to find out if the Android device has a screen or not. 我知道可以获得屏幕尺寸,但我想知道是否有人能够发现Android设备是否有屏幕。 ie whether it is a set top box or not. 即是否是机顶盒。

I guess screen size returned should be "zero", but I am not sure if that is actually the response in the real world. 我猜测返回的屏幕尺寸应为“零”,但我不确定这是否真的是现实世界中的响应。

Thank you. 谢谢。

You can check for a TV device . 您可以查看电视设备

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");
}

In staring of your code paste this code: 在盯着您的代码粘贴此代码:

    int screenSize = getResources().getConfiguration().screenLayout &
        Configuration.SCREENLAYOUT_SIZE_MASK;

String toastMsg;
switch(screenSize) {
    case Configuration.SCREENLAYOUT_SIZE_LARGE:
        toastMsg = "Large screen";
        break;
    case Configuration.SCREENLAYOUT_SIZE_NORMAL:
        toastMsg = "Normal screen";
        break;
    case Configuration.SCREENLAYOUT_SIZE_SMALL:
        toastMsg = "Small screen";
        break;
    default:
        toastMsg = "Screen size is neither large, normal or small";
}
Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show();

you can determine screen size by toastMsg . 您可以通过toastMsg确定屏幕大小。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检测android设备上的屏幕是否为触摸屏 - How do I detect whether or not the screen on an android device is a touchscreen 如何确定 Android .so 文件的 ABI(即 armeabi 或 armeabi-v7a)? - How to determine ABI of Android .so file (i.e. armeabi or armeabi-v7a)? 以编程方式确定Android设备是否具有菜单按钮的方法? - way to programatically determine whether an Android device has a menu button? 有没有办法以编程方式确定Android设备是否内置了拼写检查程序? - Is there any way to programmatically determine whether android device has builtin spellchecker? 如何在较旧的 Android 设备(即 Gingerbread 和 Froyo)上显示首选项屏幕? - How can I show a preferences screen on older Android devices i.e. Gingerbread and Froyo? Android ROOM - 如何在对象中插入对象(即 Flash Card Deck 有问题列表) - Android ROOM - How to Insert a Object inside an Object (i.e. Flash Card Deck has a List of Questions) 如何在 Android 上检查设备自然(默认)方向(即获取例如 Motorola Charm 或 Flipout 的横向) - How to check device natural (default) orientation on Android (i.e. get landscape for e.g., Motorola Charm or Flipout) 如何在Android中触发闹钟,即播放闹钟铃声? - How can I set off an alarm i.e. play an alarm tone in Android? 如何确定Android设备是否有触摸屏? - How to determine if an Android device has a touchscreen? 如何确定Android设备是否有加速度计? - How to determine if an Android device has an Accelerometer?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM