Handling Features Not Supported on TV 在电视上处理不支持的功能
来源:互联网 发布:最优化方法及其应用 编辑:程序博客网 时间:2024/05/02 18:30
TVs are much different from other Android-powered devices: http://blog.csdn.net/sergeycao
- They're not mobile.
- Out of habit, people use them for watching media with little or no interaction.
- People interact with them from a distance.
Because TVs have a different purpose from other devices, they usually don't have hardware features that other Android-powered devices often have. For this reason, the Android system does not support the following features for a TV device:
This lesson shows you how to work around features that are not available on TV by:
- Providing work arounds for some non-supported features.
- Checking for available features at runtime and conditionally activating/deactivating certain code paths based on availability of those features.
Work Around Features Not Supported on TV
Android doesn't support touchscreen interaction for TV devices, most TVs don't have touch screens, and interacting with a TV using a touchscreen is not consistent with the 10 foot environment. For these reasons, users interact with Android-powered TVs using a remote. In consideration of this, ensure that every control in your app can be accessed with the D-pad. Refer back to the previous two lessonsOptimizing Layouts for TV andOptimize Navigation for TV for more details on this topic. The Android system assumes that a device has a touchscreen, so if you want your application to run on a TV, you mustexplicitly disable the touchscreen requirement in your manifest file:
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
Although a TV doesn't have a camera, you can still provide a photography-related application on a TV. For example, if you have an app that takes, views and edits photos, you can disable its picture-taking functionality for TVs and still allow users to view and even edit photos. The next section talks about how to deactivate or activate specific functions in the application based on runtime device type detection.
Because TVs are stationary, indoor devices, they don't have built-in GPS. If your application uses location information, allow users to search for a location or use a "static" location provider to get a location from the zip code configured during the TV setup.
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);Location location = locationManager.getLastKnownLocation("static");Geocoder geocoder = new Geocoder(this);Address address = null;try { address = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1).get(0); Log.d("Zip code", address.getPostalCode());} catch (IOException e) { Log.e(TAG, "Geocoder error", e);}
TVs usually don't support microphones, but if you have an application that uses voice control, you can create a mobile device app that takes voice input and then acts as a remote control for a TV.
Check for Available Features at Runtime
To check if a feature is available at runtime, call hasSystemFeature(String)
. This method takes a single argument : a string corresponding to the feature you want to check. For example, to check for touchscreen, usehasSystemFeature(String)
with the argument FEATURE_TOUCHSCREEN
.
The following code snippet demonstrates how to detect device type at runtime based on supported features:
// Check if android.hardware.telephony feature is available.if (getPackageManager().hasSystemFeature("android.hardware.telephony")) { Log.d("Mobile Test", "Running on phone");// Check if android.hardware.touchscreen feature is available.} else if (getPackageManager().hasSystemFeature("android.hardware.touchscreen")) { Log.d("Tablet Test", "Running on devices that don't support telphony but have a touchscreen.");} else { Log.d("TV Test", "Running on a TV!");}
This is just one example of using runtime checks to deactivate app functionality that depends on features that aren't available on TVs.
- Handling Features Not Supported on TV 在电视上处理不支持的功能
- [中英文对照]android Designing for TV(三) ------ Handling Features Not Supported on TV 在TV上处理不支持的功能
- Handling Features Not Supported on TV
- Android Developers:处理在电视上不支持的功能
- 在Linux上的虚拟机上启动Oracle上报ORA-00845: MEMORY_TARGET not supported on this system的问题解决
- android TV 开发 (二) 处理电视的硬件
- Features currently not supported by Unity
- Features not supported by IOU/IOL
- ORA-00845: MEMORY_TARGET not supported on this system问题处理
- Android TV (二)(处理电视硬件)
- 【TV】海信在CES发布电视新品
- 乐视的未来押在电视上,电视成则乐视成
- ora-00845 MEMORY_TARGET not supported on this system 的问题
- ORA-00845 MEMORY_TARGET not supported on this system 的解决
- 乐视TV超级电视完胜小米电视的秘诀
- 听懂你在看什么节目,社交电视应用“酷云TV”2.0借模式识别技术推出电视节目自动识别功能
- Android TV-Handling TV Hardware
- 智能电视TV分辨率处理方案--第1问
- Optimizing Navigation for TV 优化电视导航
- 分组背包基础--1712 ACboy needs your help
- javascript 修改对象
- 进程,进程组,会话等的关系
- hdu 1004 Let the Balloon Rise
- Handling Features Not Supported on TV 在电视上处理不支持的功能
- 关于Java注释的标准化
- HDU 4190 Distributing Ballot Boxes(二分答案)
- Windows上WinRAR.exe命令行参数说明(转载) .
- sprintf函数的用法
- 用IDataObject访问剪切板
- Loading Large Bitmaps Efficiently 有效的处理较大的位图
- SQL Server中的sysobjects
- 开始我的学习之路!