I've seen many specific cases of people asking and people explaining the difference between the two but I can't and don't seem to understand the general difference. Are the two synonymous? Does one imply the other?
What is difference between permission and uses-permission in Android? permission is normally used when making a custom permission e.g. when making an app that other apps can tie in to, limiting access is a must. uses-permission is used when your app actually needs a permission it doesn't have normally.
App permissions help support user privacy by protecting access to the following: Restricted data, such as system state and a user's contact information. Restricted actions, such as connecting to a paired device and recording audio.
Google Play uses the <uses-feature> elements declared in your app manifest to filter your app from devices that do not meet its hardware and software feature requirements.
Specifies a system permission that the user must grant in order for the app to operate correctly. Permissions are granted by the user when the application is installed (on devices running Android 5.1 and lower) or while the app is running (on devices running Android 6.0 and higher).
Are the two synonymous?
No. <uses-permission>
says "hey, Android (and associated distribution channels), please ask the user to allow me to do X". <uses-feature>
says "hey, Android (and associated distribution channels), I am interested in running on hardware with feature Y".
<uses-feature>
may filter you out of the Play Store (and other channels), if the hardware does not meet your requirements, but the user doesn't get involved.
Does one imply the other?
Sometimes. If you request certain permissions, like CAMERA
, Android assumes by default that you need the corresponding hardware. You can use <uses-feature>
and android:required="false"
to override that default behavior, if needed.
It is recommended to use <uses-feature>
along with <uses-permission>
. Every feature of your app needs <uses-feature>
with attribute android:required="false"
if your app can work without it. The reason for this is that Google Play filters out applications which have features implemented programmatically but not supported by hardware, and as a result you don't see them there.
For example, among other several permissions your app has a permission <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
. If there is a device which doesn't have GPS capability, then this device will not see this app in Google Play. If your app completely functional without a GPS Connection, then the solution would be to add:
<uses-feature android:name="android.hardware.location" android:required="false"/> <uses-feature android:name="android.hardware.location.gps" android:required="false"/> <uses-feature android:name="android.hardware.location.network" android:required="false"/>
Thus, as it is already mentioned by @CommonsWare, <uses-feature>
overrides the default behaviour of <uses-permission>
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