3

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

nilMoBile
  • 1,932
  • 4
  • 15
  • 20
  • Just to be clear, you want to know if a device visits your website, does it have the required hardware (camera) to install the APK you're distributing? – Oh Danny Boy Nov 28 '11 at 21:51
  • No I want to detect when user is installing .apk? Cannot be sure that this will be hosted only my website, can be done on many others as well :( – nilMoBile Nov 28 '11 at 21:58

2 Answers2

1

Add this to your manifest:

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

uses-feature tag

Joe
  • 2,649
  • 21
  • 33
  • But this check is applied if application is installed using Android Market otherwise if any user gets apk he can install it even though his device does not have camera. – nilMoBile Nov 28 '11 at 22:53
  • have you verified that? I would think you would get an installation error when the android:required flag is set to true. If you can still install then I'm not sure there is a way to do what you are asking – Joe Nov 28 '11 at 22:58
  • Yes verified it and it does not give while installation even if device does not have a hardware support for the feature mentioned. – nilMoBile Nov 29 '11 at 12:53
  • fair enough. Then I am fairly certain there is no built in way to do what you are asking. – Joe Nov 29 '11 at 13:48
0
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