I have these:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" android:required="false" />
And I can check for GPS myself doing this:
locationManager = (LocationManager)
context.getSystemService(Context.LOCATION_SERVICE);
fSupportsGPS = (locationManager.getAllProviders().
contains(LocationManager.GPS_PROVIDER));
But I still have some doubts. I want my app to run on devices with no wifi/gps/network available. The reason being the only thing I use GPS for is showing user locaion on Google maps. (And that is a minute feature compared to rest of app, so I don't want to have any requirements for it.)
The <uses-feature ...>
tells Android that the app must require the feature and won't work w/o it, so Android doesn't let users install the app (in fact, it won't even show up in the Play Store/Market Place.
To let users who don't have those features install your app, you just have to add the android:required="false"
option for the appropriate features. That you have already done in the manifest using this XML:
<uses-feature android:name="android.hardware.camera" android:required="false"/>
To detect if the user has the feature or not (as it is now not compulsory they have it), you can use the Android APIs. This you have already done with this Java code:
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
fSupportsGPS = (locationManager.getAllProviders().contains(LocationManager.GPS_PROVIDER));
Now, one thing that you cannot do is let users using Android 1.6 and earlier w/o the features install the apps, even if the features are marked as optional. This is b'coz that version of Android doesn't recognize the android:required
feature as is explained in this answer.
Another thing to keep in mind is that some <uses-permission ...>
tags will trigger some implicit requirements for the permission.
To address this issue, quoting from the docs:
If you don't want Google Play to filter based on a specific implied feature, you can disable that behavior. To do so, declare the feature explicitly in a element and include an android:required="false" attribute. For example, to disable filtering derived from the CAMERA permission, you would declare the feature as shown below.
<uses-feature android:name="android.hardware.camera" android:required="false" />
According to this page, the <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
implies the requirement of a network. To disable that, add this to your manifest:
<uses-feature android:name="android.hardware.location.network" android:required="false" />
That android:required="false"/>
should do the trick. I have a Nexus7, which only has a frontside camera, which is not considered a camera by Android. And with the requirement on a camera it did not show up in the list of supported devices for my app on the play store.
Adding required=false as in
<uses-feature android:name="android.hardware.camera" android:required="false"/>
made it show up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With