我的 ionic 应用程序下载了一个 PDF 文件,然后尝试使用 Cordova FileOpener2 插件打开它:
var targetPath = "file:///storage/emulated/0/Android/data/myapp/files/myDir/fds/30510L109.pdf";
$cordovaFileOpener2.open(targetPath, 'application/pdf')
.then(function() {
// file opened successfully
},
function(err) {
util.logObject(err, "Open error");
});
但我收到此错误:
An error occurred: "file:///storage/emulated/0/Android/data/caliatys.edata/files/E-data/certificates/9360432001-H44K95L-en.pdf exposed beyond app through Intent.getData()"
编辑
经过一番研究和调试,我发现抛出了这个异常:FileUriExposedException。这似乎是 Android SDK 24 (链接)中引入的更改
我阅读了这个解决方案:链接,但我已经使用 cordova.file.externalDataDirectory 来保存我的 PDF ......