android程序中的AndroidManifest.xml中的uses-feature详解
来源:互联网 发布:弹簧计算软件在线 编辑:程序博客网 时间:2024/05/23 19:16
AndroidManifest.xml中的uses-feature
在Android的manifest文件:
用于指定android程序,是否需要某种硬件或软件资源/功能。
uses-feature的语法
<uses-feature android:name="string" android:required=["true" | "false"] android:glEsVersion="integer" />
android:name
- 摄像头:
android.hardware.camera
- 各种传感器:
- 加速计
: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.microphone
- 定位:
android.hardware.location
- USB:
- USB Host:
android.hardware.usb.host
- USB Host:
- WIFI:
android.hardware.wifi
- 蓝牙:
android.hardware.bluetooth
- Bluetooth Low Energy:
android.software.bluetooth_le
- VOIP:
android.software.sip.voip
http://developer.android.com/guide/topics/manifest/uses-feature-element.html#features-reference
android:required
android:required="true"
:表示需要设备具有某个功能。- 如果设备没有该功能,则程序不工作,就是可以理解的
android:required="false"
:表示希望设备,最好具有某个功能- 设备即使没有该功能,程序也应该可以正常工作
- 为了程序工作的更好,最好具有该功能。
如果不指定,默认为true:
android:required="true":
android:qlEsVersion
- OpenGL ES 1.0
- OpenGL ES 2.0
- OpenGL ES 3.0
我这里不涉及到,不去深究。
uses-feature写法举例
1.某程序需要蓝牙和摄像头,就可以这么写:
<uses-feature android:name="android.hardware.bluetooth" /><uses-feature android:name="android.hardware.camera" />
2.如果,某个设备,是类似于照相机之类的程序,那么没有摄像头,就没法正常工作,则可以加上required参数为true:
<uses-feature android:name="android.hardware.camera" android:required="true" />
3.如果某个文件共享的软件,除了通过WIFI传输外,如果有蓝牙,那最好,也支持通过蓝牙传输,则可以加上required为false,希望最好有蓝牙:
<uses-feature android:name="android.hardware.bluetooth" android:required="false" />
4.比如,我的程序,是将android设备作为USB的Host,外接USB的设备的,所以要求必须有USB的host,所以可以写为:
<uses-feature android:required="true" android:name="android.hardware.usb.host" />
uses-feature的注意事项和其他说明
uses-feature,只是起到指示性的作用,不是强制的检测
uses-feature,只是起到指示性的作用,不是强制的检测
如果像上面的,我写了:
<uses-feature android:name="android.hardware.usb.host" android:required="true" />
[2013-11-05 10:15:37 - com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] Parser exception for D:\DevRoot\xxxxxxxxxxxxxx\AndroidManifest.xml: Element type "uses-feature" must be followed by either attribute specifications, ">" or "/>".
[2013-11-05 10:15:37 - yyyy] Error in an XML file: aborting build.
<uses-feature android:required="true" android:name="android.hardware.usb.host" />
本意是:希望此android设备必须有usb的host,否则没法工作。
即使没有usb的host,该app,也是可以在该android设备上面跑的
只不过不能正常工作罢了。
而作为Android系统,是不是强制去检测:
当此android设备,没有usb的host,就不让该app运行。
写android的app时最好还是加上合适的uses-feature的说明比较好
对于其他一些程序,比如Google Play
会根据你的程序中的uses-feature的声明,去过滤,分类android的app的。
另外,你的程序中,也最好,根据实际需要,去加上合适的uses-feature的说明,比较好。
方便用户和其他人明白,你的app对于资源的需求:
至少间接的相当于:给当前app,弄了个prerequisite前提条件了。
便于用户清楚需要哪些软硬件条件,才能运行你的当前的app。
可以用aapt去检测android的app(xxx.apk)中的uses-feature属性
Testing the features required by your application
adt-bundle-windows/sdk/platform-tools/aapt.exe去拷贝了某个apk,测试了一把,结果如下:
CLi@PC-CLI-1 /cygdrive/d/DevRoot/android/adt-bundle-windows/sdk/platform-tools$ lsaapt.exe* AdbWinApi.dll* aidl.exe* crifanLiTestAapt.apk* crifanLiTestAapt_3.apk* dx.bat* lib/ NOTICE.txt* source.properties*adb.exe* AdbWinUsbApi.dll* api/ crifanLiTestAapt_2.apk* dexdump.exe* fastboot.exe* llvm-rs-cc.exe* renderscript/CLi@PC-CLI-1 /cygdrive/d/DevRoot/android/adt-bundle-windows/sdk/platform-tools$ ./aapt dump badging crifanLiTestAapt_3.apkpackage: name='com.mm.xxxxxxx' versionCode='1' versionName='1.0'sdkVersion:'14'targetSdkVersion:'17'uses-permission:'android.permission.WRITE_EXTERNAL_STORAGE'uses-feature:'android.hardware.usb.host'application-label:'MobileHandHeld'application-label-zh:'某android应用程序'application-icon-160:'res/drawable-mdpi/yyyyyyyyyy.png'application-icon-240:'res/drawable-hdpi/yyyyyyyyyy.png'application-icon-320:'res/drawable-xhdpi/yyyyyyyyyy.png'application-icon-480:'res/drawable-xxhdpi/yyyyyyyyyy.png'application: label='MobileHandHeld' icon='res/drawable-mdpi/yyyyyyyyyy.png'launchable-activity: name='com.mm.xxxxxxx.activities.DeviceListActivity' label='MobileHandHeld' icon=''uses-permission:'android.permission.READ_EXTERNAL_STORAGE'uses-implied-permission:'android.permission.READ_EXTERNAL_STORAGE','requested WRITE_EXTERNAL_STORAGE'uses-feature:'android.hardware.touchscreen'uses-implied-feature:'android.hardware.touchscreen','assumed you require a touch screen unless explicitly made optional'uses-feature:'android.hardware.screen.landscape'uses-implied-feature:'android.hardware.screen.landscape','one or more activities have specified a landscape orientation'mainother-activitiessupports-screens: 'small' 'normal' 'large' 'xlarge'supports-any-density: 'true'locales: '--_--' 'zh'densities: '160' '240' '320' '480'
AndroidManifest.xml中的<uses-feature>以及和<uses-permission>之间的联系
概述:<uses-feature>用来声明应用中需要用的硬件和软件的功能。
硬件特性:表明您的应用需要用的硬件功能。
功能类型特征描述描述音频android.hardware.audio.low_latency该应用程序使用低延迟的音频设备上的管道,声音输入或输出延迟或滞后敏感。蓝牙android.hardware.bluetooth该应用程序使用蓝牙无线功能,在设备中。相机android.hardware.camera该应用程序使用该设备的摄像头。如果设备支持多个摄像头,应用程序使用相机,面对从屏幕上移开。 android.hardware.camera.autofocus子功能。该应用程序使用设备相机的自动对焦能力。 android.hardware.camera.flash子功能。该应用程序使用设备相机的闪光灯。 android.hardware.camera.front子功能。该应用程序使用设备上的前置摄像头。 android.hardware.camera.any该应用程序使用至少一个摄像头朝向任何方向。使用当前在偏好android.hardware.camera的,
如果不需要的背面朝相机。位置android.hardware.location该应用程序使用设备上的一个或多个特征,确定位置,如GPS定位,网络位置或细胞的位置。 android.hardware.location.network子功能。该应用程序使用从设备支持的基于网络的地理定位系统获得的粗略的位置坐标 android.hardware.location.gps子功能。该应用程序使用设备上的全球定位系统接收器获得的精确位置坐标。麦克风android.hardware.microphone该应用程序使用设备上的麦克风。NFCandroid.hardware.nfc该应用程序使用近场通讯在设备的收音功能。传感器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.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.faketouch.multitouch.distinct不同的应用程序执行跟踪的两个或两个以上的“手指”上假的触摸界面。这是的faketouch功能的一个超集。 android.hardware.faketouch.multitouch.jazzhand不同的应用程序执行的跟踪5个或以上的“手指”上假的触摸界面。这是的faketouch功能的一个超集。 android.hardware.touchscreen该应用程序使用的触摸屏功能,比基本触摸事件,如一扔,更具互动性的手势。这是的基本faketouch功能的一个超集。 android.hardware.touchscreen.multitouch应用程序使用在设备屏幕上的两个基本点的多点触控功能,如捏的手势,但,不需要独立跟踪触及。这是触摸屏功能的一个超集。 android.hardware.touchscreen.multitouch.distinct子功能。在设备屏幕上的应用程序采用了先进的多点多点触控功能,如跟踪两个或两个以上的点完全独立。这是一个多点触控功能的超集。 android.hardware.touchscreen.multitouch.jazzhand在设备屏幕上的应用程序采用了先进的多点多点触控功能,跟踪到五点完全独立。这是一个独特的多点触控功能的超集。USBandroid.hardware.usb.host该应用程序使用USB主机模式功能(表现为主机和USB设备连接到)。 android.hardware.usb.accessory该应用程序使用的USB附件功能(表现为USB设备连接到USB主机)。无线上网android.hardware.wifi应用程序使用802.11网络(WIFI)功能的设备上的。 软件功能:表明您的应用程序使用或需要的软件功能。特点属性值描述应用程序!android.software.app_widgets该应用程序使用或提供应用小工具,仅应安装的设备上,包括一个主屏幕或类似的位置,用户可以应用小工具嵌入。蓝牙低功耗android.software.bluetooth_le
该应用程序使用蓝牙低能量的API只能够与其他设备通过蓝牙低功耗通信设备,应安装。这也隐含声明的android.hardware.bluetooth
功能。
子功能。该应用程序使用基于SIP的VoIP服务在设备上。
此子功能隐式声明android.software.sip的
父特征,除非宣布与
权限和功能之间的联系:
类别需要的权限要求的功能蓝牙BLUETOOTHandroid.hardware.bluetooth
(见特殊处理的蓝牙功能的详细信息。)
BLUETOOTH_ADMINandroid.hardware.bluetooth相机CAMERAandroid.hardware.camera
和 android.hardware.camera.autofocus
位置ACCESS_MOCK_LOCATIONandroid.hardware.location ACCESS_LOCATION_EXTRA_COMMANDSandroid.hardware.location INSTALL_LOCATION_PROVIDERandroid.hardware.location ACCESS_COARSE_LOCATIONandroid.hardware.location.network
和 android.hardware.location
ACCESS_FINE_LOCATIONandroid.hardware.location.gps
和 android.hardware.location
麦克风RECORD_AUDIOandroid.hardware.microphone电话CALL_PHONEandroid.hardware.telephony CALL_PRIVILEGEDandroid.hardware.telephony MODIFY_PHONE_STATEandroid.hardware.telephony PROCESS_OUTGOING_CALLSandroid.hardware.telephony READ_SMSandroid.hardware.telephony RECEIVE_SMSandroid.hardware.telephony RECEIVE_MMSandroid.hardware.telephony RECEIVE_WAP_PUSHandroid.hardware.telephony SEND_SMSandroid.hardware.telephony WRITE_APN_SETTINGSandroid.hardware.telephony WRITE_SMSandroid.hardware.telephony无线上网ACCESS_WIFI_STATEandroid.hardware.wifi CHANGE_WIFI_STATEandroid.hardware.wifi CHANGE_WIFI_MULTICAST_STATEandroid.hardware.wifi - android程序中的AndroidManifest.xml中的uses-feature详解
- android程序中的AndroidManifest.xml中的uses-feature详解
- android程序中的AndroidManifest.xml中的uses-feature详解
- android程序中的AndroidManifest.xml中的uses-feature详解
- android程序中的AndroidManifest.xml中的uses-feature详解
- AndroidManifest.xml中的<uses-feature>
- AndroidManifest.xml文件中的<uses-feature>属性详解
- AndroidManifest.xml uses-feature 详解
- AndroidManifest.xml uses-feature 详解
- AndroidManifest.xml uses-feature 详解
- AndroidManifest.xml uses-feature 详解
- AndroidManifest.xml uses-feature 详解
- AndroidManifest.xml uses-feature 详解
- AndroidManifest.xml uses-feature 详解
- AndroidManifest.xml uses-feature 详解
- AndroidManifest.xml uses-feature 详解
- AndroidManifest.xml uses-feature 详解
- AndroidManifest.xml uses-feature 详解
- H.264中NALU、RBSP、SODB的关系 (弄清码流结构)
- 在 Jelly Bean 中使用应用加密
- mysql查看锁住的表和事务隔离级别及存储过程跳出循环处理方式
- Could not create the driver from NHibernate.Driver.MySqlDataDriver
- HTML5和CSS3不仅仅是两项新的Web技术标准
- android程序中的AndroidManifest.xml中的uses-feature详解
- 数据分析工具,你选对了吗?
- 腾讯学院运营课程第一天
- Python3 基础:面向对象高级编程(上)
- 汉诺塔问题
- XML 中的 ﹤![CDATA[ ]]>,及其解析
- fedora23自动登陆root
- 蓝桥杯-查找整数
- android framelayout两布局重叠,如何让下层不响应事件