Detect GoogleTV from an Android App

Is there a way for an Android application to tell in Java code if it works on GoogleTV against tablets or phones?

+8
android google-tv
source share
4 answers

The following link may help you: Google TV Developer Guide for Android To optimize your application for Google TV, simply add an extra panel for large screens. However, if you want to determine the device that the application is currently using at run time, you can try the hasSystemFeature () method. With this, you can test certain hardware functions that are unique to Google TV (for example, you can test FEATURE_TOUCHSCREEN, since any device other than Google TV has one <=> if the function is not supported, the application probably works on the TV).

+5
source share

You can specify a package manager:

/** * Test if this device is a Google TV. * * See 32:00 in "Google I/O 2011: Building Android Apps for Google TV" * http://www.youtube.com/watch?v=CxLL-sR6XfM * * @return true if google tv */ public static boolean isGoogleTV(Context context) { final PackageManager pm = context.getPackageManager(); return pm.hasSystemFeature("com.google.android.tv"); } 

Plus this line of the manifest:

 <uses-feature android:name="com.google.android.tv" android:required="false" /> 
+10
source share

In accordance with official documents :

The recommended way to determine if your application is running on a television device is to use the UiModeManager.getCurrentModeType () method to check if the device is running in television mode. The following code example shows how to check if your application works on a television 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"); } 
+4
source share

This is how I collect useful feedback information. I do not know if it is possible to detect the type of device (phone, vs table, vs. Google TV), but it can create some mapping database and map the information to it.

 private String getDeviceInfo() { final StringBuilder sb = new StringBuilder("\n\n---\n"); try { sb.append("Version: ").append(getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName) .append('\n'); } catch (final NameNotFoundException e) { // Shouldn't happen but if did - ignore Log.e(TAG, "failed to get app version", e); } sb.append("Model: ").append(Build.MODEL).append('\n'); sb.append("Brand: ").append(Build.BRAND).append('\n'); sb.append("Device: ").append(Build.DEVICE).append('\n'); sb.append("Display: ").append(Build.DISPLAY).append('\n'); sb.append("Hardware: ").append(Build.HARDWARE).append('\n'); sb.append("Manufacturer: ").append(Build.MANUFACTURER).append('\n'); sb.append("Host: ").append(Build.HOST).append('\n'); sb.append("Release: ").append(Build.VERSION.RELEASE).append('\n'); sb.append("Board: ").append(Build.BOARD).append('\n'); sb.append("Radio: ").append(Build.RADIO).append('\n'); sb.append("Product: ").append(Build.PRODUCT).append('\n'); return sb.toString(); } 
+1
source share

All Articles