[Interest] Reading the shared Photos directory on Android

Israel Brewster ijbrewster at alaska.edu
Wed Jul 10 05:14:05 CEST 2024


I have written a Qt app, using Qt 6.6.3 that does something very simple: display photos (essentially a digital photo frame). I am trying to get it to run on Android 14. Unfortunately, as simple as this should be, I can not for the life of me figure out how to get it to request permission to access the Photos directory - and without that permission, my call to fileDir.entryList comes up empty - even though, if I call File::exists() with a file I know is in that directory, it returns true.

Things I have tried (some of which I’m sure are useless):

- add android.permission.READ_EXTERNAL_STORAGE in my AndroidManifest.xml
- add android.permission.ACCESS_MEDIA_LOCATION in my AndroidManifest.xml
- add android:requestLegacyExternalStorage=“true” to the application tag in AndroidManifest.xml
- different build-tools versions and platform SDK's
- Call the following function with the string “android.permission.READ_EXTERNAL_STORAGE”:

bool checkPermission(QString permission)
{
    auto status = QtAndroidPrivate::checkPermission(permission).result();
    if (status == QtAndroidPrivate::Denied)
    {
        status=QtAndroidPrivate::requestPermission(permission).result();
        if (status == QtAndroidPrivate::Denied)
            return false;
    }
    return true;
}


In no case does the app ever ask for permission to access the Photos (or any other) directory, and in the case of calling that function, requestPermission immediately returns Denied.

How can I access photos for my app to display?

Qt version: 6.6.3
Android version: 14, running via emulator
Android build-tools version: 34.0.0 (also tried 31.0.0)
Android build platform SDK: android-33 (also tried android-34)
JDK version 17 (tried 21 early on, but that one wouldn’t even build/deploy)
NDK version 25.1.8937393 (26.1.10909125 and 27.0.11902837 don’t create any kits, so not using them)
Building using Qt Creator version 12.0.2 on MacOS

---
Israel Brewster
Software Engineer
Alaska Volcano Observatory 
Geophysical Institute - UAF 
2156 Koyukuk Drive 
Fairbanks AK 99775-7320
Work: 907-474-5172
cell:  907-328-9145

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20240709/0132e91f/attachment.htm>


More information about the Interest mailing list