创建TV应用Helloworld_第1页
创建TV应用Helloworld_第2页
创建TV应用Helloworld_第3页
创建TV应用Helloworld_第4页
创建TV应用Helloworld_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、 TV apps use the same structure as those for phones and tablets. This similarity means you can modify your existing apps to also run on TV devices or create new apps based on what you already know about building apps for Android.电视应用和手机以及平板使用相同的架构。这样就意味着我们可以修改现存的应用到电视设备上或者创建新的应用在电视上用类似于你所知的其他的构建应用程序

2、的方式Important: There are specific requirements your app must meet to qualify as an Android TV app on Google Play. For more information, see the requirements listed in TV App Quality.重点:想把android电视的应用放在google play中要满足一些得顶的要求,可以参考Tv App Quality的列表This lesson describes how to prepare your development en

3、vironment for building TV apps, and the minimum required changes to enable an app to run on TV devices.本课程将描述如何准备电视应用的开发环境,最小的需求改变使得应用运行中电视设备上See the following documentation for information about the codecs, protocols, and formats supported by Android TV. - Supported Media Formats - DRM - android.dr

4、m - ExoPlayer - android.media.MediaPlayer查看以下文档信息,包括代码,协议和Android TV支持的格式。Set up a TV Project创建TV项目This section discusses how to modify an existing app to run on TV devices, or create a new one. These are the main components you must use to create an app that runs on TV devices:这一部分将讨论如何修改现存的应用到电视上运

5、行,或者创建一个新的电视应用。这些僵尸最主要的组建我们必须使用来创建一个电视应用中电视设备上* Activity for TV (Required) - In your application manifest, declare an activity that is intended to run on TV devices. * TV Support Libraries (Optional) - There are several Support Libraries available for TV devices that provide widgets for building use

6、r interfaces. 电视活动(必须) - 在您的manifest中, 声明一个可在TV设备上运行的activity。 电视支持库(可选) - 这些支持库Support Libraries 可以提供搭建TV用户界面的控件。Prerequisites前提条件Before you begin building apps for TV, you must:在创建TV应用前, 必须做以下事情:* Update your SDK tools to version 24.0.0 or higher The updated SDK tools enable you to build and test

7、apps for TV. 更新sdk工具版本到24或者以上,升级的sdk版本使得构架电视测试应用变的可用* Update your SDK with Android 5.0 (API 21) or higher The updated platform version provides new APIs for TV apps.更新你的sdk在android5.0或者以上,升级的平台版本提供了新的电视应用程序接口* Create or update your app project In order to access new APIs for TV devices, you must cre

8、ate a project or modify an existing project that targets Android 5.0 (API level 21) or higher.创建或者升级应用程序项目来访问新的电视应用程序接口,必须创建或者修改现存的项目,版本这android5.0及其以上Declare a TV Activity声明一个电视ActivityAn application intended to run on TV devices must declare a launcher activity for TV in its manifest using a CATEG

9、ORY_LEANBACK_LAUNCHER( intent filter. This filter identifies your app as being enabled for TV, and is required for your app to be considered a TV app in Google Play. Declaring this intent also identifies which activity in your app to launch when a user selects its icon on the TV home screen.想要一个应用程序

10、运行中电视设备上必须声明一个加载activity在manifest文件中使用intent filter包含CATEGORY_LEANBACK_LAUNCHER。这个过滤器说明你的应用是在TV上可用,并且为Google Play上发布TV应用所必须。定义这个intent也意味着点击主屏幕的应用图标时,就是打开的这个activity。The following code snippet shows how to include this intent filter in your manifest:接下来的代码片段显示如何在manifest中包含这个intent filter:<applic

11、ation android:banner="drawable/banner" > . <activity android:name="com.example.android.MainActivity" android:label="string/app_name" > <intent-filter> <action android:name="ent.action.MAIN" /> <category android:name="and

12、ent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.example.android.TvActivity" android:label="string/app_name" android:theme="style/Theme.Leanback"> <intent-filter> <action android:name="and

13、ent.action.MAIN" /> <category android:name="ent.category.LEANBACK_LAUNCHER" /> </intent-filter> </activity></application>The second activity manifest entry in this example specifies that activity as the one to launch on a TV device.例子中第二个a

14、ctivity manifest定义的activity是TV设备中的一个启动入口。> *Caution*: If you do not include the CATEGORY_LEANBACK_LAUNCHER( intent filter in your app, it is not visible to users running the Google Play store on TV devices. Also, if your app does not have this filter when you load it onto a TV device using develo

15、per tools, the app does not appear in the TV user interface.Caution:如果在你的应用中不包含CATEGORY_LEANBACK_LAUNCHER intent filter,它不会出现在TV设备的Google Play商店中。并且,即使你把不包含此filter的应用用开发工具装载到TV设备中,应用仍然不会出现在TV用户界面上。If you are modifying an existing app for use on TV, your app should not use the same activity layout fo

16、r TV that it does for phones and tablets. The user interface of your TV app (or TV portion of your existing app) should provide a simpler interface that can be easily navigated using a remote control from a couch. For guidelines on designing an app for TV, see the TV Design( guide. For more informat

17、ion on the minimum implementation requirements for interface layouts on TV, see Building TV Layouts(如果你正在为TV设备修改现有的应用,就不应该与手机和平板用同样的activity布局。TV的用户界面(或者现有应用的TV部分)应该提供一个更简单的界面,更容易坐在沙发上用遥控器操作。TV应用设计指南,参考电视设计指导。查看TV界面布局的最低要求,参考:电视布局# Declare Leanback support声明Leanback支持Declare that your app uses the L

18、eanback user interface required by Android TV. If you are developing an app that runs on mobile (phones, wearables, tablets, etc.) as well as Android TV, set the required attribute value to false. If you set the required attribute value to true, your app will run only on devices that use the Leanbac

19、k UI.Android TV需要你的应用使用Leanback用户界面。如果你正在开发一个运行在移动设备(手机,可穿戴,平板等等)也包括TV的应用,设置required属性为false。因为如果设置为true,你的应用将仅能运行在用Leanback UI的设备上。<manifest> <uses-feature android:name="android.software.leanback" android:required="false" /> .</manifest># Declare touchscreen no

20、t required声明不需要触屏Applications that are intended to run on TV devices do not rely on touch screens for input. In order to make this clear, the manifest of your TV app must declare that a the android.hardware.touchscreen feature is not required. This setting identifies your app as being able to work o

21、n a TV device, and is required for your app to be considered a TV app in Google Play. The following code example shows how to include this manifest declaration:运行在TV设备上的应用不依靠触屏去输入。为了清楚表明这一点,TV应用的manifest必须声明android.hardware.touchscreen为不需要。这个设置表明应用能够工作在TV设备上,并且也是Google Play认定你的应用为TV应用的要求。接下来的示例代码展示这

22、个manifest声明:<manifest> <uses-feature android:name="android.hardware.touchscreen" android:required="false" /> .</manifest>>*Caution*: You must declare that a touch screen is not required in your app manifest, as shown this example code, or your app cannot appe

23、ar in the Google Play store on TV devices.Caution:必须在manifest中声明触屏是不需要的,否则应用不会出现在TV设备的Google Play商店中。# Provide a home screen banner提供一个主屏幕横幅An application must provide a home screen banner for each localization if it includes a Leanback launcher intent filter. The banner is the app launch point that

24、 appears on the home screen in the apps and games rows. Desribe the banner in the manifest as follows:如果应用包含一个Leanback的intent filter,它必须提供每个语言的主屏幕横幅。横幅是出现在应用和游戏栏的主屏的启动点。在manifest中这样描述横幅:<application . android:banner="drawable/banner" > .</application>Use the android:banner attr

25、ibute with the application tag to supply a default banner for all application activities, or with the activity tag to supply a banner for a specific activity.在应用节点中添加banner属性为所有的应用activity提供默认的横幅,或者在特定activity的中添加横幅。See Banners( in the UI Patterns for TV design guide.在UI模式和TV设计指导中查看“旗帜”# Add TV Supp

26、ort Libraries添加TV支持库The Android SDK includes support libraries that are intended for use with TV apps. These libraries provide APIs and user interface widgets for use on TV devices. The libraries are located in the <sdk>/extras/android/support/ directory. Here is a list of the libraries and th

27、eir general purpose:Android SDK包含用于TV应用的支持库。这些库为TV设备提供API和用户界面控件。这些库位于<sdk>/extras/android/support/目录。以下是这些库的列表和它们的作用介绍:* v17 leanback library( - Provides user interface widgets for TV apps, particularly for apps that do media playback. * v7 recyclerview library( - Provides classes for managin

28、g display of long lists in a memory efficient manner. Several classes in the v17 leanback library depend on the classes in this library. * v7 cardview library( - Provides user interface widgets for displaying information cards, such as media item pictures and descriptions. v17 leanback library - 提供T

29、V应用的用户界面控件,特别是用于媒体播放应用的控件。 v7 recyclerview library - 提供了内存高效方式的长列表的管理显示类。有一些v17 leanback库的类依赖于本库的类。 v7 cardview library - 提供显示信息卡的用户界面控件,如媒体图片和描述。>*Note*: You are not required to use these support libraries for your TV app. However, we strongly recommend using them, particularly for apps that pro

30、vide a media catalog browsing interface.Note:TV应用中可以不用这些库。但是,我们强烈推荐使用它们,特别是为应用提供媒体目录浏览界面时。If you decide to use the v17 leanback library for your app, you should note that it is dependent on the v4 support library( This means that apps that use the leanback support library should include all of these

31、 support libraries:如果我们决定用v17 leanback library,我们应该注意它依赖于v4支持库。这意味着要用leanback支持库必须包含以下所有的支持库: v4 support library v7 recyclerview support library v17 leanback support libraryThe v17 leanback library contains resources, which require you to take specific steps to include it in app projects. For instru

32、ctions on importing a support library with resources, see Support Library Setup.v17 leanback library包含资源文件,需要你在应用中采取特定的步骤去包含它。插入带资源文件的支持库的说明,查看支持库安装向导# Build TV Apps创建TV应用After you have completed the steps described above, it's time to start building apps for the big screen! Check out these addi

33、tional topics to help you build your app for TV:在完成上面的步骤之后,到了给大屏幕创建应用的时候了!检查一下这些额外的专题可以帮助我们创建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 con

34、tent 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. * Games for TV( - TV devices are

35、 a great platform for games. See this topic for information on building great game experiences for TV. 创建电视播放应用- TV就是用来娱乐的,因此安卓提供了一套用户界面工具和控件,用来创建视频和音乐的TV应用,并且让用户浏览想看到的内容。 帮助用户找到电视内容- 因为所有的内容选择都用手指操作遥控器,所以帮助用户找到想要的内容几乎和提供内容同样重要。这个主题讨论如何在TV设备中处理内容。 电视游戏- TV设备是非常好的游戏平台。参考这个主题去创造更好的TV游戏体验。# Run TV Apps运行TV应用Running your app is an important part of the development process. The AVD Manager in the Android SDK provides the devi

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论