Dar*_*ell 10
您可以询问包管理员:
/**
* 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");
}
Run Code Online (Sandbox Code Playgroud)
加上这个清单行:
<uses-feature android:name="com.google.android.tv" android:required="false" />
Run Code Online (Sandbox Code Playgroud)
根据官方文件:
确定您的应用是否在电视设备上运行的推荐方法是使用UiModeManager.getCurrentModeType()方法检查设备是否在电视模式下运行.以下示例代码显示了如何检查您的应用是否在电视设备上运行:
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");
}
Run Code Online (Sandbox Code Playgroud)
以下链接可能对您有所帮助:Google TV Android开发人员指南要优化Google TV的应用,只需为大屏幕添加额外的选择.但是,如果要在运行时确定当前正在使用该应用程序的设备,可以尝试使用hasSystemFeature()方法.通过这种方式,您可以测试Google TV独有的某些硬件功能(例如,您可以测试FEATURE_TOUCHSCREEN,因为任何设备除了Google TV都有一个<=>如果该功能不受支持,该应用可能正在电视上运行) .
| 归档时间: |
|
| 查看次数: |
2874 次 |
| 最近记录: |