<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                > 編寫:[awong1900](https://github.com/awong1900) - 原文:[http://developer.android.com/training/tv/start/start.html](http://developer.android.com/training/tv/start/start.html) TV應用使用與手機和平板同樣的架構。這種相似性意味著你可以修改現有的應用到TV設備或者用以前安卓應用的經驗開發TV應用。 > **Important**: 在Google Play中的TV應用應滿足一些特定要求。更多信息, 參考[TV App Quality](http://developer.android.com/distribute/essentials/quality/tv.html)中的要求列表。 本課程介紹如何準備您的TV應用開發環境,和使應用能夠運行在TV設備上所必須的最小改變。 ### 創建TV項目 本節討論如何修改已有的應用或者新建一個應用使之能夠運行在電視設備上。在TV設備運行的應用必須使用這些主要組件: - **[Activity](# "An activity represents a single screen with a user interface.") for TV** (必須) - 在您的application manifest中, 聲明一個可在TV設備上運行的[activity](# "An activity represents a single screen with a user interface.")。 - **TV Support Libraries** (可選) - 這些支持庫[Support Libraries](http://developer.android.com/training/tv/start/start.html#tv-libraries) 可以提供搭建TV用戶界面的控件。 ### 前提條件 在創建TV應用前, 必須做以下事情: - [更新SDK tools到版本24.0.0或更高](http://developer.android.com/sdk/installing/adding-packages.html#GetTools) 最新的SDK tools能確保編譯和測試TV應用 - [更新SDK為Android 5.0 (API 21)或更高](http://developer.android.com/sdk/installing/adding-packages.html#GetTools) 最新的platform版本提供TV應用的新API - [創建或更新應用項目](http://developer.android.com/sdk/installing/create-project.html) 為了支持TV新API, 你必須設置新項目或者修改原項目的目標平臺為Android 5.0 (API level 21)或者更高。 ### 聲明一個TV [Activity](# "An activity represents a single screen with a user interface.") 一個應用想要運行在TV設備中,必須在它的manifest中定義一個啟動[activity](# "An activity represents a single screen with a user interface."),用intent filter包含[CATEGORY_LEANBACK_LAUNCHER](http://developer.android.com/reference/android/content/Intent.html#CATEGORY_LEANBACK_LAUNCHER)。這個filter表明你的應用是在TV上可用,并且為Google Play上發布TV應用所必須。定義這個intent也意味著在點擊app在TV主屏幕的圖標時,打開的就是這個[activity](# "An activity represents a single screen with a user interface.")。 接下來的代碼片段顯示如何在manifest中包含這個intent filter: ~~~ <application android:banner="@drawable/banner" > ... <activity android:name="com.example.android.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.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="android.intent.action.MAIN" /> <category android:name="android.intent.category.LEANBACK_LAUNCHER" /> </intent-filter> </activity> </application> ~~~ 例子中第二個[activity](# "An activity represents a single screen with a user interface.")的manifest是TV設備中的一個啟動入口。 > **Caution**:如果在你的應用中不包含[CATEGORY_LEANBACK_LAUNCHER](http://developer.android.com/reference/android/content/Intent.html#CATEGORY_LEANBACK_LAUNCHER) intent filter,它不會出現在TV設備的Google Play商店中。并且,即使你把不包含此filter的應用用開發工具裝載到TV設備中,應用仍然不會出現在TV用戶界面上。 如果你正在為TV設備修改現有的應用,不應該與手機和平板用同樣的[activity](# "An activity represents a single screen with a user interface.")布局。TV的用戶界面(或者現有應用的TV部分)應該提供一個更簡單的界面,更容易坐在沙發上用遙控器操作。TV應用設計指南,參考[TV Design](http://developer.android.com/design/tv/index.html)指導。查看TV界面布局的最低要求,參考:[Building TV Layouts](http://developer.android.com/training/tv/start/layouts.html)。 ### 聲明Leanback支持 安卓TV需要你的應用使用Leanback用戶界面。如果你正在開發一個運行在移動設備(手機,可穿戴,平板等等)同時也包含安卓TV的應用,設置`required`屬性為`false`。因為如果設置為`true`,你的應用將僅能運行在用Leanback UI的設備上。 ~~~ <manifest> <uses-feature android:name="android.software.leanback" android:required="false" /> ... </manifest> ~~~ ### 聲明不需要觸屏 運行在TV設備上的應用不依靠觸屏去輸入。為了清楚表明這一點,TV應用的manifest必須聲明`android.hardware.touchscreen`為不需要。這個設置表明應用能夠工作在TV設備上,并且也是Google Play認定你的應用為TV應用的要求。接下來的示例代碼展示這個manifest聲明: ~~~ <manifest> <uses-feature android:name="android.hardware.touchscreen" android:required="false" /> ... </manifest> ~~~ > **Caution**:必須在manifest中聲明觸屏是不需要的,否則應用不會出現在TV設備的Google Play商店中。 ### 提供一個主屏幕橫幅 如果應用包含一個Leanback的intent filter,它必須提供每個語言的主屏幕橫幅。橫幅是出現在應用和游戲欄的主屏的啟動點。在manifest中這樣描述橫幅: ~~~ <application ... android:banner="@drawable/banner" > ... </application> ~~~ 在[`application`](http://developer.android.com/guide/topics/manifest/application.html)中添加[`android:banner`](http://developer.android.com/guide/topics/manifest/application-element.html#banner)屬性為所有的應用[activity](# "An activity represents a single screen with a user interface.")提供默認的橫幅,或者在特定的[activity](# "An activity represents a single screen with a user interface.")的[`activity`](http://developer.android.com/guide/topics/manifest/activity-element.html)中添加橫幅。 在UI模式和TV設計指導中查看[Banners](http://developer.android.com/design/tv/patterns.html#banner)。 ### 添加TV支持庫 Android SDK包含用于TV應用的支持庫。這些庫為TV設備提供API和用戶界面控件。這些庫位于`<sdk>/extras/android/support/`目錄。以下是這些庫的列表和它們的作用介紹: - [v17 leanback library](http://developer.android.com/tools/support-library/features.html#v17-leanback) - 提供TV應用的用戶界面控件,特別是用于媒體播放應用的。 - [v7 recyclerview library](http://developer.android.com/tools/support-library/features.html#v7-recyclerview) - 提供了內存高效方式的長列表的管理顯示類。有一些v17 leanback庫的類依賴于本庫的類。 - [v7 cardview library](http://developer.android.com/tools/support-library/features.html#v7-cardview) - 提供顯示信息卡的用戶界面控件,如媒體圖片和描述。 > **Note**:TV應用中可以不用這些庫。但是,我們強烈推薦你使用它們,特別是為應用提供媒體目錄瀏覽界面時。 如果你決定用`v17 leanback library`,你應該注意它依賴于[v4 support library](http://developer.android.com/tools/support-library/features.html#v4)。這意味著要用leanback支持庫必須包含以下所有的支持庫: - v4 support library - v7 recyclerview support library - v17 leanback support library `v17 leanback library`包含資源文件,需要你在應用中采取特定的步驟去包含它。插入帶資源文件的支持庫的說明,查看[Support Library Setup](http://developer.android.com/tools/support-library/setup.html#libs-with-res)。 ### 創建TV應用 在完成上面的步驟之后,到了給大屏幕創建應用的時候了!檢查一下這些額外的專題可以幫助您創建TV應用: - [創建TV播放應用](http://developer.android.com/training/tv/playback/index.html) - TV主要是用來娛樂,因此安卓提供了一套用戶界面工具和控件,用來創建視頻和音樂的TV應用,并且讓用戶瀏覽想看到的內容。 - [幫助用戶找到TV內容](http://developer.android.com/training/tv/discovery/index.html) - 因為所有的內容選擇操作都用手指操作遙控器,所以幫助用戶找到想要的內容幾乎和提供內容同樣重要。這個主題討論如何在TV設備中處理內容。 - [TV游戲](http://developer.android.com/training/tv/games/index.html) - TV設備是非常好的游戲平臺。參考這個主題去創造更好的TV游戲體驗。 ### 運行TV應用 在開發過程中運行應用是一個重要的部分。在安卓SDK中的AVD管理器提供了創建虛擬TV設備的功能,可以讓應用在虛擬設備中運行和測試。 創建一個虛擬TV設備 1. 打開AVD管理器。更多信息,參考[AVD管理器](http://developer.android.com/tools/help/avd-manager.html)幫助。 1. 在AVD管理器窗口,點擊**Device Definitions**標簽。 1. 選擇安卓一個TV設備定義,并且點擊**Create AVD**。 1. 選擇模擬器選項并且點擊**OK**創建AVD。 > **Note**:獲得TV模擬器設備的最佳性能,打開**Use Host GPU option**,支持虛擬設備加速。更多模擬器硬件加速信息,參考[Using the Emulator](http://developer.android.com/tools/devices/emulator.html#acceleration)。 在虛擬設備中測試應用 1. 在開發環境中編譯TV應用。 1. 從開發環境中運行應用并選擇目標為TV虛擬設備。 更多模擬器信息:[Using the Emulator](http://developer.android.com/tools/devices/emulator.html)。 用Android Studio部署應用到模擬器,查看[Debugging with Android Studio](http://developer.android.com/sdk/installing/studio-debug.html)。用帶ADT插件的Eclipse部署應用到模擬器,查看[Building and Running from Eclipse with ADT ](http://developer.android.com/tools/building/building-eclipse.html)。 [下一節: 處理TV硬件](#)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看