標籤:
<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> 的說明