標籤:android style blog http io color ar os 使用
參考資料:http://developer.android.com/guide/topics/manifest/uses-feature-element.html
<uses-feature>標籤位於<manifest>標籤中,可以允許多個,用於聲明應用依賴的硬體或者軟體功能。但這僅限於聲明,安裝時並不會真正檢查這些功能。真正代碼中用到功能,還是需要通過PackageManager去判斷當前環境是否支援。這些聲明真正的目的是用於告訴外界應用是為怎麼樣的裝置設計的,這可以讓其他服務(比如市集)或者其他應用擷取一些資訊並與之互動,為合適的裝置推薦合適的應用。
文法:
<uses-feature android:name="string" android:required=["true" | "false"] android:glEsVersion="integer" />
屬性:
android:name
依賴的硬體或軟體功能名
android:required
如果為true,則表示這個裝置的這個功能是必須的,應用缺少這個功能將無法正常運行。
如果為false,則表示這個裝置的這個功能並非必須,應用缺少這個功能可以正常運行。
預設值為true
android:glEsVersion
如果應用需要依賴OpenGL ES,則需要在這裡填版本號碼。版本號碼用一個整數表示,整數高16位表示大版本號碼,低16位表示小版本號碼,比如OpenGL ES 2.0的版本號碼為0x00020000。整個應用最多聲明一個glEsVersion,如果有多處聲明,則取版本號碼最大的那個。如果應用沒有聲明這個屬性,則預設為OpenGL ES 1.0。OpenGL ES是向下相容的,所以只需要聲明需要版本最高的那個。
動態方式擷取功能資訊:
當應用運行時需要某個裝置功能,需要先判斷裝置是否支援。通過PackageManager.getSystemAvailableFeatures方法可以擷取裝置所有支援的功能;通過PackageManager.hasSystemFeature方法可以判斷裝置是否支援某個功能。
通過PackageInfo.reqFeatures可以擷取某個應用所有聲明的功能依賴。
硬體功能表:
注意子功能需要父功能聲明過,至少android:required="false"
音頻
android.hardware.audio.low_latency
低延時音頻通道,用於對延時比較銘感的情境。
藍芽
android.hardware.bluetooth
藍芽功能
android.hardware.bluetooth_le
藍芽 4.0 LE(Bluetooth Smart)
網路攝影機
android.hardware.camera
網路攝影機功能
android.hardware.camera.autofocus
自動對焦
android.hardware.camera.flash
閃光燈
android.hardware.camera.front
自拍
android.hardware.camera.any
任何方向的網路攝影機
android.hardware.camera.external
擴充網路攝影機
紅外
android.hardware.consumerir
紅外通訊
定位
android.hardware.location
使用一種或者多種方式定位
android.hardware.location.network
使用網路定位
android.hardware.location.gps
使用gps定位
麥克風
android.hardware.microphone
麥克風功能
近距離無線通訊
android.hardware.nfc
近距離無線通訊功能
android.hardware.nfc.hce
HCE功能
感應器
android.hardware.sensor.accelerometer
加速器
android.hardware.sensor.barometer
氣壓計
android.hardware.sensor.compass
羅盤
android.hardware.sensor.gyroscope
陀螺儀
android.hardware.sensor.light
光線感應器
android.hardware.sensor.proximity
近程感應器
android.hardware.sensor.stepcounter
計步器
android.hardware.sensor.stepdetector
步伐檢測器
螢幕
android.hardware.screen.landscape
橫屏
android.hardware.screen.portrait
豎屏
如果應用支援兩個方向,是不需要聲明上面兩個功能的。
電話
android.hardware.telephony
電話功能
android.hardware.telephony.cdma
cdma通話
android.hardware.telephony.gsm
gsm通話
電視
android.hardware.type.television
電視功能
觸屏
android.hardware.faketouch
基本觸屏功能,只能點擊
android.hardware.touchscreen
支援手勢的觸摸功能。預設已經聲明了這個功能,如果要聲明應用可以支援非觸摸,可以把required設為false
android.hardware.touchscreen.multitouch
兩點觸控
android.hardware.faketouch.multitouch.distinct
兩點或者多點點擊觸控
android.hardware.faketouch.multitouch.jazzhand
五點或者更多點擊觸控
android.hardware.touchscreen.multitouch.distinct
兩點或者多點觸控
android.hardware.touchscreen.multitouch.jazzhand
五點或者更多觸控
USB
android.hardware.usb.host
作為USB主機連接埠功能
android.hardware.usb.accessory
作為USB用戶端功能
WIFI
android.hardware.wifi
使用wifi功能
android.hardware.wifi.direct
wifi直連功能
軟體功能表:
android.software.app_widgets
提供案頭組件功能
android.software.device_admin
提供裝置管理員功能
android.software.home_screen
提供自訂主屏程式功能
android.software.input_methods
提供自訂IME功能
android.software.live_wallpaper
提供自訂動態壁紙功能
android.software.sip
提供SIP功能
android.software.sip.voip
提供類比訊號數字化功能
另外在代碼中使用系統提供的硬體軟體功能需要聲明相應的許可權,下面是功能和許可權對照表:
http://developer.android.com/guide/topics/manifest/uses-feature-element.html#permissions
AndroidManifest.xml的<uses-feature>節點