Customizing the Reference TV App
2017-11-13 16:00
288 查看
本文转载自:https://source.android.google.cn/devices/tv/customize-tv-app
Live TV is a reference TV app designed for Android television devices. However,device manufacturers may want to add more product-specific functions, which arenot covered by the default implementation of Live TV, such as pictureadjustment, game mode, or 3D
mode. To support these device-specific functions oroptions, Live TV supports these customizations:
Enabling time-shifting mode, which allows users to pause, fast forward, and rewind. Configuring time-shifting mode to use external storage instead of internal storage.
Adding options to the TV options row.
Adding a custom row and adding options in it.
Note:
LiveChannels is Google's implementation of Live TV that can be used as is ondevices with Google services. To customize Live Channels, replace
Live TV searches for a system package with this permission, checks the resourcefiles, and detects the package's
Activitiesmarked with specific
categoriesto process customization.
Key point: Only one package can customize Live TV.
Play controls UI. Time-shifting is enabled by default inLive TV, but can be disabled. Time-shifting can also be configured to useexternal storage only.
To configure time-shifting, add the string resource
Figure 1. Play controls UI is activated after pressing theD-pad center button.
To indicate a custom option, declare an intent-filter that filters the category
is clicked. The activity's title and icon are used forthe option. Customized TV options should match the existing UI to provide thebest user experience.
Note: An activity can only handle one optionbecause Live TV cannot differentiate intent-filters in an activity with the samecategory due to the Android limitation. See
Handle multiple options in anactivity for a workaround.
Device manufacturers can also place a custom option before or after the existingoptions by defining
are sorted by their priority in ascendingorder. If options have the same priority, order among them is undefined.
In this example, the option appears first in the TV options row, andPictureSettingsActivity launches if the option is clicked.
Figure 2. Sample customized TV options row (Brightness andEnergy Saving).
Figure 3. Sample custom TV options.
options in an activity, use
Figure 4. Sample optional custom row.
Figure 5. Sample custom option dialog.
Live TV is a reference TV app designed for Android television devices. However,device manufacturers may want to add more product-specific functions, which arenot covered by the default implementation of Live TV, such as pictureadjustment, game mode, or 3D
mode. To support these device-specific functions oroptions, Live TV supports these customizations:
Enabling time-shifting mode, which allows users to pause, fast forward, and rewind. Configuring time-shifting mode to use external storage instead of internal storage.
Adding options to the TV options row.
Adding a custom row and adding options in it.
Note:
LiveChannels is Google's implementation of Live TV that can be used as is ondevices with Google services. To customize Live Channels, replace
com.android.tv.*with
com.google.android.tv.*in theseinstructions.
Customizing Live TV
To customize Live TV, the target Android TV device needs a customization packageinstalled, which must be a prebuilt system app with thecom.android.tv.permission.CUSTOMIZE_TV_APPpermission.
Live TV searches for a system package with this permission, checks the resourcefiles, and detects the package's
Activitiesmarked with specific
categoriesto process customization.
Key point: Only one package can customize Live TV.
Configuring time-shifting mode
Time-shifting (trickplay) allows Android television devices to pause, rewind,and fast forward channel playback. In the Live TV implementation, time-shiftingcan be used via thePlay controls UI. Time-shifting is enabled by default inLive TV, but can be disabled. Time-shifting can also be configured to useexternal storage only.
To configure time-shifting, add the string resource
trickplay_modeand set its value to one of these options:
enabled: Enable time-shifting. This is the default value when no options are given.
disabled: Disable time-shifting.
use_external_storage_only: Configure time-shifting to use external storage.
<string name="trickplay_mode">use_external_storage_only</string>
Figure 1. Play controls UI is activated after pressing theD-pad center button.
Customizing TV options
Device manufacturers can add custom options for Live TV settings to the existingTV options menu, such as adding a shortcut to the Sound Picture settings.To indicate a custom option, declare an intent-filter that filters the category
com.android.tv.category.OPTIONS_ROWin an activity. The custom featureis implemented by the device manufacturer in the activity. The activitylaunches if the option
is clicked. The activity's title and icon are used forthe option. Customized TV options should match the existing UI to provide thebest user experience.
Note: An activity can only handle one optionbecause Live TV cannot differentiate intent-filters in an activity with the samecategory due to the Android limitation. See
Handle multiple options in anactivity for a workaround.
Device manufacturers can also place a custom option before or after the existingoptions by defining
android:priorityin
AndroidManifest.xml.An option with a defined priority value lower than 100 shows before the existingitems and a value higher than 100 shows after. Multiple custom options (eitherbefore or after existing options)
are sorted by their priority in ascendingorder. If options have the same priority, order among them is undefined.
In this example, the option appears first in the TV options row, andPictureSettingsActivity launches if the option is clicked.
<activity android:name=".PictureSettingsActivity" android:label="@string/activity_label_picture_settings" android:theme="@style/Theme.Panel"> <intent-filter android:icon="@drawable/ic_tvoptions_brightness" android:label="@string/option_label_brightness" android:priority="0"> <action android:name="android.intent.action.MAIN" /> <category android:name="com.android.tv.category.OPTIONS_ROW" /> </intent-filter> </activity>
Figure 2. Sample customized TV options row (Brightness andEnergy Saving).
Figure 3. Sample custom TV options.
Handling multiple options in an activity
An option maps to an activity's intent-filter and vice-versa. Because Androiddoesn't differentiate intent-filters with the same categories and actions, anactivity only handles one option, even if multiple intent-filters are declaredin it. To handle multipleoptions in an activity, use
<activity-alias>in
AndroidManifest.xml. In theactivity, use
getIntent().getComponent()to identify the clicked option.
<activity-alias android:name=".AnyUniqueName" android:targetActivity=".PictureSettingsActivity"> <intent-filter android:icon="@drawable/ic_tvoptions_energy_saving" android:label="@string/option_label_energy_saving" android:priority="1"> <action android:name="android.intent.action.MAIN" /> <category android:name="com.android.tv.category.OPTIONS_ROW" /> </intent-filter> </activity-alias>
Creating a custom row
Device manufacturers can add and customize a row above the TV options row.This custom row is optional.Row Title
Define apartner_row_titlestring in
res/values/strings.xml. The string's value is used for the customrow title.
<string name="partner_row_title">Partner Row</string>
Custom options
To add custom options to the custom row, follow the process for adding optionsto the TV options menu, but change the category name tocom.android.tv.category.PARTNER_ROWinstead.
<activity android:name=".ThreeDimensionalSettingDialogActivity" android:label="@string/activity_label_3d" android:theme="@android:style/Theme.Material.Light.Dialog"> <intent-filter android:icon="@drawable/ic_tvoptions_3d" android:priority="0"> <action android:name="android.intent.action.MAIN" /> <category android:name="com.android.tv.category.PARTNER_ROW" /> </intent-filter> </activity>
Figure 4. Sample optional custom row.
Figure 5. Sample custom option dialog.
相关文章推荐
- The app references non-public selectors in Payload
- The app references non-public selector in MyApp : id
- Your app uses or references the following non-public APIs的解决方案
- Your app uses or references the following non-public APIs的解决方案
- The app references non-public selectors in Payload
- (app 上架问题)the app references non-public selectors in playload/app/app:expires
- 解决Xcode上传出现的Error ITMS-9000问题 ,No image found at the path referenced under key CFBundleIcons AppIcon
- The app references non-public selectors in payload With Xcode6.1
- .net4 wpf App 使用log4net 错误:The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)
- The app references non-public selectors in payload With Xcode6.1
- The app references non-public selectors in payload With Xcode6.1
- iOS开发遇到的坑之七--上传app Stroe被拒绝:The app references non-public symbols in : _UICreateCGImageFromIOSurface
- The source code of the Account class of the famous IM app
- Android开发 Error:The number of method references in a .dex file cannot exceed 64K.
- JNI--JNI ERROR (app bug): accessed stale local reference
- Cannot make a static reference to the non-static method getLocalActivityManager()
- the type java.io.ObjectInputStream cannot be resolved. it is indirectly referenced from required .cl
- RuntimeException: Type "nmethodBucket*", referenced in VMStructs::localHotSpotVMStructs in the remot
- android App title theme
- The type javax.servlet.http.HttpServletRequest cannot be resolved. It is indirectly referenced from