Android TV-Handling TV Hardware
》After you have completed the steps described above, it's time to start building apps for the big screen! Check out these additional topics to help you build your app for TV:
- Building TV Playback Apps - TVs are built to entertain, so Android provides a set of user interface tools and widgets for building TV apps that play videos and music, and let users browse for the content they want.
- Helping Users Find Your Content on TV - With all the content choices at users' fingertips, helping them find content they enjoy is almost as important as providing that content. This training discusses how to surface your content on TV devices.
- Building TV Games - TV devices are a great platform for games. See this topic for information on building great game experiences for TV.
- Building Live TV Apps - Present your video content in a linear, "broadcast TV" style with channels and programs that your users can access through a program guide as well as the channel up/down buttons.
》To create an virtual TV device:
- Start the AVD Manager. For more information, see the AVD Manager help.
- In the AVD Manager dialog, click the Device Definitions tab.
- Select one of the Android TV device definitions and click Create AVD.
- Select the emulator options and click OK to create the AVD.
Note: For best performance of the TV emulator device, enable the Use Host GPU option and, where supported, use virtual device acceleration.
To test your application on the virtual TV device:
- Compile your TV application in your development environment.
- Run the application from your development environment and choose the TV virtual device as the target.
TV hardware is substantially different from other Android devices. TVs do not include some of the
hardware features found on other Android devices, such as touch screens, cameras, and GPS receivers. TVs are also completely dependent on secondary hardware devices. In order for users to interact with TV apps, they must use a remote control or game pad. When
you build an app for TV, you must carefully consider the hardware limitations and requirements of operating on TV hardware.
》The recommended way to determine if your app is running on a TV device is to use theUiModeManager.getCurrentModeType()
method
to check if the device is running in television mode. The following example code shows you how to check if your app is running on a TV 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") }》 to declare that your app does not require hardware features which are unavailable on TV devices, even though your app may use these features on non-TV devices:
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/> <uses-feature android:name="android.hardware.faketouch" android:required="false"/> <uses-feature android:name="android.hardware.telephony" android:required="false"/> <uses-feature android:name="android.hardware.camera" android:required="false"/> <uses-feature android:name="android.hardware.nfc" android:required="false"/> <uses-feature android:name="android.hardware.location.gps" android:required="false"/> <uses-feature android:name="android.hardware.microphone" android:required="false"/> <uses-feature android:name="android.hardware.sensor" android:required="false"/>
Note: Some features have subfeatures like android.hardware.camera.front
, as described in the Feature
Reference. Be sure to mark as required="false"
any subfeatures also used in your app.
Caution: Declaring
a hardware feature as required by setting its value to true
prevents your app from being installed on TV devices or appearing in the Android TV home
screen launcher.
》Use the hasSystemFeature(String)
method
to check for specific features at runtime.
// Check if the telephony hardware feature is available. if (getPackageManager().hasSystemFeature("android.hardware.telephony")) { Log.d("HardwareFeatureTest", "Device can make phone calls"); } // Check if android.hardware.touchscreen feature is available. if (getPackageManager().hasSystemFeature("android.hardware.touchscreen")) { Log.d("HardwareFeatureTest", "Device has a touch screen."); }
》 TVs are stationary, indoor devices, and do not have built-in global positioning system (GPS) receivers. If your app uses location information, you can still allow users to search for a location, or use a static location provider such as a zip code configured during the TV device setup.
// Request a static location from the location manager LocationManager locationManager = (LocationManager) this.getSystemService( Context.LOCATION_SERVICE); Location location = locationManager.getLastKnownLocation("static"); // Attempt to get postal or zip code from the static location object 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); }The default controller for a TV device is a D-pad. In general, your app should be operable from a remote controller that only has up, down, left, right, select, Back, and Home buttons. If your app is a game that typically requires a game controller with additional controls, your app should attempt to allow gameplay with these D-pad controls. In this case, your app should also warn the user that a controller is required and allow them to exit your game gracefully using the D-pad controller.
Controllers for TV are frequently Bluetooth devices which may attempt to save power by periodically going into sleep mode and disconnecting from the TV device. This means that an app might be interrupted or restarted if it is not configured to handle these reconnect events. These events can happen in any of the following circumstances:
- While watching a video which is several minutes long, a D-Pad or game controller goes into sleep mode, disconnects from the TV device and then reconnects later on.
- During gameplay, a new player joins the game using a game controller that is not currently connected.
- During gameplay, a player leaves the game and disconnects a game controller.
相關文章
- Android TV開發——RecyclerView For TVAndroidView
- Android TVAndroid
- Android TV-Building Layouts for TVAndroidUI
- android tv-Building TV GamesAndroidUIGAM
- android tv-TV Apps ChecklistAndroidAPP
- android TV-Building TV Channels,Developing a TV Input ServiceAndroidUIdev
- 通過 Hardware Layer 提升 Android 動畫效能Android動畫
- Android TV-Creating TV NavigationAndroidNavigation
- android TV-Recommending TV Content,Android
- Android TV-Building TV Apps,Get Started with TV AppsAndroidUIAPP
- android TV-Making TV Apps Searchable,Searching within TV AppsAndroidAPP
- Android Jetpack - Android TV 應用開發教程AndroidJetpack
- Android TV開發總結【RecycleView】AndroidView
- android TV-Working with Channel DataAndroid
- android tv-Managing User InteractionAndroid
- STM32 Hardware Developmentdev
- 一起看 I/O | Google TV 和 Android TV OS 的最新進展GoAndroid
- stf 怎麼使用在 android tv 上Android
- Android TV版小米盒子專版亮相Android
- Android TV端RecyclerView焦點亂跑AndroidView
- [譯]利用 Android 構建 TV 的未來Android
- [譯] 利用 Android 構建 TV 的未來Android
- [譯]SearchFragment --Android TV 開發手冊十二FragmentAndroid
- 聊聊真實的 Android TV 開發技術棧Android
- Configure Pi as simulation hardware for Simulink
- 如何在Android TV 桌面新增自定義頻道/節目Android
- 小米和Google合作:Android TV版小米盒子進軍美國GoAndroid
- docker desktop : Hardware assisted virtualization and data execution protectionDocker
- Java TV MHPJava
- Android TV版電視盒子亮相 小米和Google看著樂AndroidGo
- android TV - Creating a Catalog Browser,Providing a Card ViewAndroidView
- android TV-Building a Details View,Displaying a Now Playing CardAndroidUIAIView
- PcMagazine:羅技TV、谷歌TV、Roku XDS三大網際網路TV引數對比谷歌
- Android TV曝出bug 或導致使用者私人照片洩露Android TV新漏洞:你的照片可能出現在他人的電視中!Android
- win10電腦藍屏提示hardware怎麼辦_win10電腦藍屏提示hardware修復方法Win10
- 電腦開機提示Hardware Monitor解決方法?
- Tasks of a Database Administrator : Evaluate the Database Server Hardware (7)DatabaseServer
- Google:Android TV月活裝置數已超8000萬臺GoAndroid