How to make sure an android device application supports hardware feature

陌路散爱 提交于 2019-12-23 17:46:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!