如何确保android设备应用程序支持硬件功能



我正在开发一个广泛使用相机的应用程序。我想做的是,如果一个设备或平板电脑没有摄像头,我的应用程序不应该安装在它。

检查了android清单中的<uses-feature>,但只检查应用程序是通过android marketplace安装的。如果我打算它也可用我的网站。有没有办法让应用程序在设备没有摄像头硬件的情况下不被安装?

谢谢,~ nil

将此添加到您的manifest:

   <uses-feature android:name="android.hardware.camera" android:required="true" />

uses-feature标记

You can use code to check device support feature :
PackageManager pm = getPackageManager();
if (!pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_COMPASS)) {
    // This device does not have a compass, turn off the compass feature
    disableCompassFeature();
}
preference link : http://developer.android.com/guide/practices/compatibility.html#Features

最新更新