Android 關於 <uses-feature> 的說明

來源:互聯網
上載者:User

標籤:

 <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> 的說明

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.