1

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?

BKnows
  • 117
  • 1
  • 9
  • 1
    I bet that searching for "qt android fileprovider" should do the thing – Selvin Mar 29 '19 at 13:41
  • Thanks, I that search query was what I was looking for, this blog describes the usage of the FileProvider really good: https://blog.qt.io/blog/2017/12/01/sharing-files-android-ios-qt-app/ – BKnows Mar 29 '19 at 15:15
  • 2
    the problem is that if you are "only qt guy" you will not know about fileprovider ... that's why it would be hard to get right query :) – Selvin Mar 29 '19 at 15:17

0 Answers0