androidTV相關(guān)開(kāi)發(fā)指導(dǎo)1-創(chuàng)新互聯(lián)

谷歌電視相關(guān)開(kāi)發(fā)api

10年積累的網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶(hù)對(duì)網(wǎng)站的新想法和需求。提供各種問(wèn)題對(duì)應(yīng)的解決方案。讓選擇我們的客戶(hù)得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站設(shè)計(jì)后付款的網(wǎng)站建設(shè)流程,更有湞江免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

#### google tv 1 設(shè)置tv App

1.升級(jí)開(kāi)發(fā)工具到最新版本

2.manifest設(shè)置

 2.1 android:theme="@style/Theme.Leanback"

 2.2 <category android:name="android.intent.category.LEANBACK_LAUNCHER" />

<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>

3 觸屏支持 不支持觸屏操作

<uses-feature android:name="android.hardware.touchscreen"

       android:required="false" />

4. 提供一個(gè)橫幅用于所有的activity,或者針對(duì)每一個(gè)activity設(shè)置屬性

<application

  ...

  android:banner="@drawable/banner" >

  ...

</application>

5.添加Android TV 支持庫(kù) 目錄 <sdk>/extras/android/support/

5.1 v17 leanback library  提供tv用戶(hù)界面部件,特別用于媒體應(yīng)用

5.2 v7 recycleview library 高效管理長(zhǎng)列表內(nèi)容內(nèi)存,leanback需要

5.3 v7  cardview library 顯示信息卡片 特別是媒體圖片和描述

但是,以上支持庫(kù)不是必須使用的,但是推薦在媒體分類(lèi)的瀏覽的應(yīng)用中使用。

如果你使用了leanback 包,就不用使用 v4包,v7reycle包河v17 leanbackback

包。

v17包包含一些資源文件,必須把那些資源文件導(dǎo)入到你的app。

和v7包的加入方式一樣:https://developer.android.com/tools/support-library/setup.html#libs-with-res

6 硬件相關(guān)檢測(cè) api13

UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);

if (uiModeManager.getCurrentModeType()==Configuration.UI_MODE_TYPE_TELEVISION) {

 // tv 模式

}else if (uiModeManager.getCurrentModeType()==Configuration.UI_MODE_TYPE_CAR) {

//汽車(chē)

}

7.在tv上,不支持的硬件特性

觸屏操作 , 撥打電話(huà),視頻,近場(chǎng)通信,gps定位,麥克風(fēng)支持

Hardware Android feature descriptor

--------------------------------------------------------------------------------

Touchscreen android.hardware.touchscreen

Telephony android.hardware.telephony

Camera android.hardware.camera

Near Field Communications (NFC) android.hardware.nfc

GPS android.hardware.location.gps

Microphone android.hardware.microphone

設(shè)置:

<uses-feature android:name="android.hardware.touchscreen"

    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.gps"

    android:required="false"/>

<uses-feature android:name="android.hardware.microphone"

    android:required="false"/>

如果,設(shè)置為true,你的程序可能就不會(huì)出現(xiàn)在電視設(shè)備選項(xiàng),和出現(xiàn)在tv設(shè)備的主屏幕上。

8. 權(quán)限permissions 和硬件特性

Permission 權(quán)限 Implied hardware feature需要硬件特性

--------------------------------------------------------------

RECORD_AUDIO android.hardware.microphone

CAMERA android.hardware.camera and  android.hardware.camera.autofocus

ACCESS_COARSE_LOCATION android.hardware.location and android.hardware.location.network

ACCESS_FINE_LOCATION android.hardware.location and android.hardware.location.gps

8.1 檢查系統(tǒng)是否支持這些硬件特性

// 檢查是否支持電話(huà)特性

if (getPackageManager().hasSystemFeature("android.hardware.telephony")) {

  Log.d("HardwareFeatureTest", "Device can make phone calls");

}

// 檢查是否支持屏幕滑動(dòng)

if (getPackageManager().hasSystemFeature("android.hardware.touchscreen")) {

  Log.d("HardwareFeatureTest", "Device has a touch screen.");

}

8.2 Touch screen android不支持的觸摸屏,因?yàn)殡娨曈^(guān)看環(huán)境不統(tǒng)一。

8.3 Camera ,雖然沒(méi)有攝像頭功能,但是還是支持圖片的查看和編輯。

<uses-feature android:name="android.hardware.camera" android:required="false" />

// Check if the camera hardware feature is available.

if (getPackageManager().hasSystemFeature("android.hardware.camera")) {

  Log.d("Camera test", "Camera available!");

} else {

  Log.d("Camera test", "No camera available. View and edit features only.");

}

8.4 GPS功能

android不支持GPS功能,但是你還是可以要求用戶(hù)搜索一個(gè)地址配置到電視設(shè)備上。,

// 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);

}

9 手持設(shè)備電視控制器 Handling Controllers

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線(xiàn),公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。

當(dāng)前標(biāo)題:androidTV相關(guān)開(kāi)發(fā)指導(dǎo)1-創(chuàng)新互聯(lián)
標(biāo)題鏈接:http://bm7419.com/article8/dgdgop.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化手機(jī)網(wǎng)站建設(shè)、網(wǎng)站維護(hù)網(wǎng)站策劃、商城網(wǎng)站、用戶(hù)體驗(yàn)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁(yè)設(shè)計(jì)公司