Android Question RuntimePermissions confusion

Discussion in 'Android Questions' started by JohnC, Apr 16, 2019.

  1. JohnC

    JohnC Well-Known Member Licensed User

    I am finally working with runtime permissions for the first time and I am confused about something...

    From what I understand, a statement like below is needed in the manifest when the app is running on a version of android that does not support runtime permissions.

    "18" />
    And it is my understanding that the "18" parameter means "This permission statement is only applicable for devices running android API level 18 or less".

    And from what I also understand, Android 6.0 (API 23) is when runtime permissions were implemented.

    So, what is confusing to me is what happens when the app is run on a device with an API level of 19 (android 4.4) to 22 (android 5.1)?

    Meaning, if the manifest declaration is only valid for device API's up to level 18, then what happens when the app runs on a lollipop device (android 5.0, API 21) and it needs to access the contacts, but android 5.0 does not support runtime permissions?
  2. Erel

    Erel Administrator Staff Member Licensed User

    You have misunderstood. The maxSdkVersion is only relevant to one specific permission, the storage permission. Watch the video tutorial.
  3. JohnC

    JohnC Well-Known Member Licensed User

    I did watch the video and it talked about the storage example, and since it did not mention that maxSdkVersion was ONLY for the "storage" permission, that lead me to believe the maxSdkVersion should be used in the manifest for the other dangerous permissions so that the app can run on android versions before version 6.0.

    So, then if my app needs to access the contacts, then I should place the following statement in the manifest?

    And just so I understand this correctly, if I do include the above line in my app's manifest, would the below things then happen?

    1) When installing the app on a device running android 4-5.1, it will immediately pop-up a dialog saying that the app requires access to the contacts, and
    2) If the app is installed on a device running android 6+, it will NOT immediately pop-up a dialog when installing an app, but it will eventually pop-up a permission prompt when my code runs the first "rp.CheckAndRequest(rp.permission.READ_CONTACTS)"?
  4. Erel

    Erel Administrator Staff Member Licensed User

    No. It will be added automatically like it always did.

    1) It will show the list of permissions during installation.
    2) True.

    In all cases you need to call rp.CheckAndRequest. Don't try to call it based on the device version.
  5. JohnC

    JohnC Well-Known Member Licensed User

    Ah, thank you - that clears up a lot.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice