问题
I am developing an application which uses camera extensively. What I wish to do is that if a device or tablet does not have camera it my application should not get installed on it.
Checked the <uses-feature>
in android manifest but only checks when application is installed via android marketplace. What if I intend it to be also available my site. So is there a way I can handle this so that application should not get installed in case device does not have a camera hardware?
Thanks, ~nil
回答1:
Add this to your manifest:
<uses-feature android:name="android.hardware.camera" android:required="true" />
uses-feature tag
回答2:
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
来源:https://stackoverflow.com/questions/8302719/how-to-make-sure-an-android-device-application-supports-hardware-feature