Oreo (WRITE EXTERNAL STORAGE) Permission

后端 未结 7 1770
攒了一身酷
攒了一身酷 2020-12-29 23:47

According to \"developer.android.com\"

If the app targets Android 8.0 (API level 26), the system grants only 
READ_EXTERNAL_STORAGE at that time; however, i         


        
7条回答
  •  没有蜡笔的小新
    2020-12-30 00:09

    For Oreo,

    you need to explicitly do a READ_EXTERNAL_STORAGE request (by code) even if you have already requested and is granted the WRITE_EXTERNAL_STORAGE permission, and vis versa.

    prior to this, READ_EXTERNAL_STORAGE is automatically granted when WRITE_EXTERNAL_STORAGE is granted.

    so what you need to do, is to

    1) ask for WRITE permission in your codes.

    2) when user grants the WRITE permission, ask again for READ permission - this will be automatically granted (you will get an exception if you do not ask for a READ explicitly)

    The changes for Oreo doesn't make much sense to me (no idea why do we need to ask for a permission that is automatically granted), but that is what it is.

    https://developer.android.com/about/versions/oreo/android-8.0-changes.html#rmp

提交回复
热议问题