Skip to content

Instantly share code, notes, and snippets.

@rocboronat
Created June 27, 2015 15:43
Show Gist options
  • Save rocboronat/894389c135bf2cc152cd to your computer and use it in GitHub Desktop.
Save rocboronat/894389c135bf2cc152cd to your computer and use it in GitHub Desktop.
A Util to useful and common Android TV things
package com.fewlaps.electroswingrevolution.util;
import android.app.UiModeManager;
import android.content.Context;
import android.content.res.Configuration;
import android.util.Log;
/**
* @author Roc Boronat ([email protected])
* @date 27/06/2015
*/
public class AndroidTVUtils {
public static boolean isAndroidTV(Context context) {
UiModeManager uiModeManager = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
Log.d("TV", "Running on a TV Device");
return true;
} else {
Log.d("TV", "Running on a non-TV Device");
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment