Is there a way to open local files on Android with Qt 5.12.x?

477 Views Asked by At

I try top open a pdf on Android, which I have downloaded to:

QStandardPaths::writableLocation(QStandardPaths::TempLocation)

Code to open the PDF:

QUrl url;
if (filePath.startsWith("\\\\") || filePath.startsWith("//")) {
  url.setUrl(QDir::toNativeSeparators(filePath));
} else {
  url = QUrl::fromLocalFile(filePath);
}
return QDesktopServices::openUrl(url);

I get the following error:

android.os.FileUriExposedException: file:///data/user/0/my.app/cache/myPDF.pdf exposed beyond app through Intent.getData()

Is there a way to solve that issue with Qt?

0

There are 0 best solutions below