2

Due to Google's Privacy Policies updates, if the main purpose of your app is not to access storage/gallery on a continuous basis (like social media apps), Google does not approve the app to be published on the Play Store if READ_MEDIA_IMAGES or MANAGE_EXTERNAL_STORAGE is declared in the Manifest file. Google says that Image Picker (limited access to the gallery) can be used instead of these permissions.

However, since the application supports a wide variety of versions (API 23 and above), the READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permission control returns false on API 33 and above devices in case of permission request, so the relevant operation cannot be performed, although Image Picker is used.

Pseudocode that what I am doing:

if (hasStoragePermission()) {
    doSomething() // like access galery
} else {
    requestStoragePermission()
}
fun hasStoragePermission() : Boolean {
    return 
        if (Build.Version_Code >= Tiramisu) {
            true // I know that this way is not good but if I control the READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE, it returns false
        } else {
            hasPermission(READ_EXTERNAL_STORAGE) && hasPermission(WRITE_EXTERNAL_STORAGE)
        }
}
fun requestStoragePermission() : Boolean {
    if (Build.Version_Code >= Tiramisu) {
            requestPermission(READ_EXTERNAL_STORAGE)
        } else {
            requestPermission(READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE)
        }
}

Note: If your app targets Build.VERSION_CODES.R or higher, WRITE_EXTERNAL_STORAGE has no effect.

Long story short, I am using Image Picker for all supported APIs, but API 32 and lower, I have to request READ and WRITE External Storage, so I am requesting and checking the status correctly. However API 33 and above, I cannot request any Storage or Media related permission due to privacy policy.

How should I handle the storage permission for API 33 and above?

2
  • What are you trying to do, pick an image the user took and do something with it? Commented Nov 27, 2024 at 19:13
  • @tyczj, yes , kind of. It depends on the activity/fragment, such as picking qr image from galery, saving generated qr code to storage etc. Commented Nov 27, 2024 at 19:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.