Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Using QDesktopServices with Android 11 scoped storage
Forum Updated to NodeBB v4.3 + New Features

Using QDesktopServices with Android 11 scoped storage

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 295 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    emyrcatsor
    wrote on last edited by
    #1

    Hi,
    My Qt6 Android application creates .html files in the local storage using QStandardPaths:

    QString fileName=QDir(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation)).filePath("example.html");
    QFile file(fileName);
    if (file.open(QIODevice::WriteOnly)) {
        file.write(getHTMLString());
        file.close();
    }
    

    In the past, I used to make the device browser app open the newly created file by calling QDesktopServices:

    QDesktopServices::openUrl(QUrl::fromLocalFile(fileName));
    

    However, since Android 11 has made its scoped storage concept mandatory, QDesktopServices fails in opening browser apps. Only file managers and other apps that (I suppose) declare the MANAGE_EXTERNAL_STORAGE permission are able to open the file.

    What is the most straightforward way to make Android open my local .html files with the default browser?

    Many thanks in advance for your help!

    1 Reply Last reply
    1

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved