Results 1 to 1 of 1

Thread: Android + MANAGE_EXTERNAL_STORAGE permissions problem.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2025
    Posts
    1
    Platforms
    Unix/X11 Android

    Default Android + MANAGE_EXTERNAL_STORAGE permissions problem.

    Hi,

    I am making a C++ Qt (Qt6.9.0) application for Linux, and I am calling:

    Qt Code:
    1. QString folderPath = QFileDialog::getExistingDirectory(this, "Select Folder");
    To copy to clipboard, switch view to plain text mode 

    The dialog appears, but there appears the message: "Can't use this folder. To protect your privacy, choose another folder". I am trying to use the root of the internal storage and the root of the SD card.

    The following permissions are granted on the app:

    D/default : Permissions found: 6
    D/default : Permission: "android.permission.ACCESS_NETWORK_STATE"
    D/default : Permission: "android.permission.INTERNET"
    D/default : Permission: "android.permission.MANAGE_EXTERNAL_STORAGE"
    D/default : Permission: "android.permission.READ_EXTERNAL_STORAGE"
    D/default : Permission: "android.permission.WRITE_EXTERNAL_STORAGE"
    D/default : Permission: "org.qtproject.example.uiarchivos.DYNAMIC_RECEIVER _NOT_EXPORTED_PERMISSION"

    I configured the ones for the storage in the CMakeLists.txt file:

    ....
    Qt Code:
    1. # Define Android permissions
    2. set_property(TARGET androidBrowser PROPERTY QT_ANDROID_PERMISSIONS
    3. "android.permission.READ_EXTERNAL_STORAGE"
    4. "android.permission.WRITE_EXTERNAL_STORAGE"
    5. "android.permission.MANAGE_EXTERNAL_STORAGE"
    6. )
    To copy to clipboard, switch view to plain text mode 
    .....

    In main.cpp I do:

    Qt Code:
    1. int main(int argc, char *argv[]) {
    2. QApplication app(argc, argv);
    3. requestPermissions(); // does nothing unless it is Android.
    4. ....etc, code to print the permissions that I got and code for my aplication...
    5. return app.exec();
    6. }
    To copy to clipboard, switch view to plain text mode 

    With requestPermissions as follows:

    Qt Code:
    1. void requestPermissions()
    2. {
    3. #ifdef Q_OS_ANDROID
    4. QJniObject activity = QNativeInterface::QAndroidApplication::context();
    5. QJniEnvironment env;
    6.  
    7. QStringList permissions = {
    8. "android.permission.READ_EXTERNAL_STORAGE",
    9. "android.permission.WRITE_EXTERNAL_STORAGE",
    10. "android.permission.MANAGE_EXTERNAL_STORAGE"
    11. };
    12.  
    13. jclass stringClass = env->FindClass("java/lang/String");
    14. jobjectArray jPermissions = env->NewObjectArray(permissions.size(), stringClass, nullptr);
    15.  
    16. for (int i = 0; i < permissions.size(); ++i) {
    17. QJniObject jstr = QJniObject::fromString(permissions[i]);
    18. env->SetObjectArrayElement(jPermissions, i, jstr.object<jstring>());
    19. }
    20.  
    21. QJniObject::callStaticMethod<void>(
    22. "androidx/core/app/ActivityCompat",
    23. "requestPermissions",
    24. "(Landroid/app/Activity;[Ljava/lang/String;I)V",
    25. activity.object<jobject>(),
    26. jPermissions,
    27. 1
    28. );
    29. #endif
    30. }
    To copy to clipboard, switch view to plain text mode 

    In addition, in the android emulator, I go to settings->Apps->[my applicatioin]->Permissions files and media->Files and Media and selected Allow management of all files.

    So, what can I do? Is there something that I am missing? Why can't I select those folders?

    I have seen QCoreApplication::requestPermission() API, but there is no permission for storage.

    Thank you in advance,

    Carlos
    Last edited by d_stranz; 27th June 2025 at 02:01. Reason: missing [code] tags

Similar Threads

  1. Weird Windows Vista Permissions Causing Qmake Crash
    By CrazyIvanovich in forum Qt Programming
    Replies: 1
    Last Post: 4th June 2009, 21:52
  2. qmake DESTDIR permissions behavior (Unix)
    By wdezell in forum Qt Tools
    Replies: 3
    Last Post: 9th March 2009, 14:59
  3. Replies: 1
    Last Post: 27th September 2008, 20:12
  4. Replies: 3
    Last Post: 11th September 2008, 20:08
  5. Replies: 1
    Last Post: 20th June 2008, 18:43

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.