Difference Between uses-permission-sdk-23 and uses-permission?
if the app is running on a device with SDK version 23 or higher. If the device is running SDK version 22 or lower
when you update an app to include a new feature that requires an additional permission. If a user updates an app on a device that is running SDK version 22 or lower, the system prompts the user at install time to grant all new permissions that are declared in that update. If a new feature is minor enough, you may prefer to disable the feature altogether on those devices, so the user does not have to grant additional permissions to update the app. By using the uses-permission-sdk-23 element instead of uses-permission
you can request the permission only if the app is running on platforms that support the runtime permissions model, in which the user grants permissions to the app while it is running.
for More info refer this.uses - Permission sdk 23
Summary
<uses-permission>
applies to all SDKs and <uses-permission-sdk-23>
will apply the permission only to SDK 23+.
When should you use <uses-permission-sdk-23>
?
For Android SDK 23 and above, you have the option to request the permission at runtime but the permissions will be in their default state upon installation and the user will not be prompted at installation. (Essentially this can be used to prompt the user to grant the permission on a need-to-use basis and you have the opportunity to provide an explanation of why it's needed.)
However, for SDK 22 and below, the user is prompted at installation for permissions. As some permissions can seem suspicious or dodgy to the user, you may not want to request these for SDK 22 and below as you can't provide an explaination of why you need them beforehand, hence the
<uses-permission-sdk-23>
tag.Additionally: the documentation is unclear as to whether
sdk-23
permissions also cause the app to be filtered in the Play Store, but if it was your intention to do this, the documentation recommends that you make use of<uses-feature>
elements instead to declare hardware compatability.
Recommendation
Generally, it is considered best practice to use <uses-permission-sdk-23>
if your app does not need to support SDK 22 and below, or if the permission you are requesting is not needed for SDK 22 or below as it is then clear that this permission is requested at runtime.
Otherwise, <uses-permission>
should be used as this is backwards compatible and the behavior will be correct on any SDK version; 22 and below, permissions will be requested at installation. 23 and above, it's up to you to request at runtime.
You should request permissions at runtime wherever possible as it allows you to explain to your user why you need certain permissions rather than just prompting them with a list of permissions at install time when the user has likely not established trust in the app.
Notes
Both of these accept a maxSdkVersion
attribute that can be used when a permission was required for older devices but is not required for newer devices. (For example, the WRITE_EXTERNAL_STORAGE
example shown in the Android documentation.)
Reference: (Android Documentation)