Using QDesktopServices with Android 11 scoped storage
Unsolved
Mobile and Embedded
-
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!