Difference Between uses-permission-sdk-23 and uses-permission?

前端 未结 6 1038
名媛妹妹
名媛妹妹 2021-02-05 05:17

I just come to know newer tag in android manifest file called \"uses-permission-sdk-23\"



        
6条回答
  •  自闭症患者
    2021-02-05 05:36

    Summary

    applies to all SDKs and will apply the permission only to SDK 23+.

    When should you use ?

    • 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 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 elements instead to declare hardware compatability.

    Recommendation

    Generally, it is considered best practice to use 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, 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)

提交回复
热议问题