Mr.Noob
Mr.Noob

Reputation: 1005

How to determine if the device is an android tablet or an android TV

Is there a way to determine if the device is an android tablet or a TV? I know we could determine it using layout bins but then again tablets come in different sizes now a days. According to my knowledge TV UI is using 960dp layouts? at the same time there are tablets that use 960dp layouts as well. so is there a way of properly outline the two devices?

Upvotes: 1

Views: 1382

Answers (1)

Rolf ツ
Rolf ツ

Reputation: 8781

Google published a nice check for that.

UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
    Log.d("TV", "Running on a TV Device")
} else {
    Log.d("TV", "Running on a non-TV Device")
}

Source

Upvotes: 3

Related Questions