Skip to content

Instantly share code, notes, and snippets.

@slobodin
Created October 10, 2018 20:33
Show Gist options
  • Save slobodin/9f70dde9c678a65259062cc7eea57167 to your computer and use it in GitHub Desktop.
Save slobodin/9f70dde9c678a65259062cc7eea57167 to your computer and use it in GitHub Desktop.
public static boolean isAndroidTV() {
try {
Activity activity = GameActivity.getSharedActivity();
UiModeManager uiModeManager = (UiModeManager) activity.getSystemService(UI_MODE_SERVICE);
if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
MyLog.i(TAG, "Running on a TV Device");
return true;
} else {
MyLog.i(TAG, "Running on a non-TV Device");
return false;
}
} catch (Exception e) {
MyLog.e(TAG, "Failed to call isAndroidTV");
MyLog.e(TAG, e.getMessage());
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment