Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

No permission to open file on Android with Qt 5.15



  • Hi,

    I want to open a PDF file in Qt 5.15 on Android. I use

    QDesktopServices::openUrl(QUrl(file));
    

    to open the file. In Qt 5.15 this function should work on Android. (Bugfix from here: QTBUG-45585)
    Unfortunately I always get the error:

    Qt JAVA : openURL(): No permissions to open Uri
    

    If I test the permissions:

    qDebug() << "file: " << file;
    QFile f(file);
    qDebug() << "file exists: " << f.exists();
    f.setPermissions(QFileDevice::ReadUser | QFileDevice::WriteUser);
    qDebug() << f.permissions();
    

    I get the following:

    /storage/emulated/0/Documents/doc.pdf
    file exists:  true
    QFlags(0x20|0x40|0x200|0x400|0x2000|0x4000)
    

    I have set android permissions for READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE in manifest.xml and also proofed the permission by:

    QtAndroid::PermissionResult r = QtAndroid::checkPermission("android.permission.READ_EXTERNAL_STORAGE");
     if(r == QtAndroid::PermissionResult::Granted) 
    ...
    

    If I generate a FileDialog to open the PDF there is no issue - the file opens normally.
    Does anyone have an idea or has anyone solved a similar problem?

    Thank you.



  • I opened a bug about this issue: QTBUG-85011


Log in to reply