Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uses-Permission vs Uses-Feature

Tags:

java

android

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?

like image 592
Kevin L. Avatar asked Jan 22 '15 00:01

Kevin L.


People also ask

What is the difference between permission and uses permission?

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.

What are the uses of permission?

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.

What uses feature?

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.

What is the uses permission in Android?

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).


Video Answer


2 Answers

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.

like image 127
CommonsWare Avatar answered Sep 20 '22 14:09

CommonsWare


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>

like image 36
Ayaz Alifov Avatar answered Sep 19 '22 14:09

Ayaz Alifov