码迷,mamicode.com
首页 > 移动开发 > 详细

Android 关于 <uses-feature> 的说明

时间:2015-08-11 19:34:17      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:

 <uses-feature>  主要还是被Play使用的.例子:

<uses-feature android:name="android.hardware.touchscreen"         android:required="true"/>
如果设备没有这个touchscreen这个硬件,  play就不会把app安装到这个设备上.false的话还是会安装上.


Android apps can declare hardware feature requirements in the app manifest to ensure that they do not get installed on devices that do not provide those features. If you are extending an existing app for use on TV, closely review your app‘s manifest for any hardware requirement declarations that might prevent it from being installed on a TV device.

Some features have subfeatures like android.hardware.camera.front, as described in the Feature Reference. Be sure to mark as required="false" any subfeatures also used in your app.

舉例來說,我的App會使用到Camera,但不是必要的。為此我宣告了Camera的<uses-permission>,但省略了<uses-feature>。

<uses-permission android:name="android.permission.CAMERA" />

此時Google Play發現了這個<uses-permission>,便會將Camera視為必要而進行過濾,沒有Camera的裝置就看不到我的App了,這樣跟我想要的結果不同。设置为false就没有这个问题了!


另外, App内部也可以判断是否支持这个硬件

// 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.");
}






Android 关于 <uses-feature> 的说明

标签:

原文地址:http://my.oschina.net/sfshine/blog/490796

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!