How to determine if an Android device has a screen i.e. whether it is an Android set top box?
Asked Answered
T

1

6

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. i.e. 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.

Tagmemics answered 24/4, 2015 at 5:4 Comment(0)
B
4

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");
}
Beholden answered 24/4, 2015 at 5:17 Comment(1)
That doesn't work because it checks the UI layout which is the same for Android STBs and Android TVsConsider

© 2022 - 2024 — McMap. All rights reserved.