androidTV相关开发指导1-创新互联

谷歌电视相关开发api

10年积累的网站建设、成都网站设计经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有浈江免费网站建设让你可以放心的选择与我们合作。

#### google tv 1 设置tv App

1.升级开发工具到最新版本

2.manifest设置

 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. 提供一个横幅用于所有的activity,或者针对每一个activity设置属性

<application

  ...

  android:banner="@drawable/banner" >

  ...

</application>

5.添加Android TV 支持库 目录 <sdk>/extras/android/support/

5.1 v17 leanback library  提供tv用户界面部件,特别用于媒体应用

5.2 v7 recycleview library 高效管理长列表内容内存,leanback需要

5.3 v7  cardview library 显示信息卡片 特别是媒体图片和描述

但是,以上支持库不是必须使用的,但是推荐在媒体分类的浏览的应用中使用。

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

包。

v17包包含一些资源文件,必须把那些资源文件导入到你的app。

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

6 硬件相关检测 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) {

//汽车

}

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

触屏操作 , 拨打电话,视频,近场通信,gps定位,麦克风支持

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

设置:

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

如果,设置为true,你的程序可能就不会出现在电视设备选项,和出现在tv设备的主屏幕上。

8. 权限permissions 和硬件特性

Permission 权限 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 检查系统是否支持这些硬件特性

// 检查是否支持电话特性

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

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

}

// 检查是否支持屏幕滑动

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

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

}

8.2 Touch screen android不支持的触摸屏,因为电视观看环境不统一。

8.3 Camera ,虽然没有摄像头功能,但是还是支持图片的查看和编辑。

<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功能,但是你还是可以要求用户搜索一个地址配置到电视设备上。,

// 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 手持设备电视控制器 Handling Controllers

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

当前标题:androidTV相关开发指导1-创新互联
标题链接:https://www.cdcxhl.com/article8/dgdgop.html

成都网站建设公司_创新互联,为您提供关键词优化手机网站建设网站维护网站策划商城网站用户体验

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都网页设计公司