android - 不允许加载本地资源 : ionic 3 android

标签 android file path ionic3 android-6.0-marshmallow

我正在使用 ionic 3 android build apk 并尝试从 file:///storage/emulated/0/data/io.ionic.vdeovalet/cache/image.jpeg




    takePicture(sourceType) {
        try {
    // Create options for the Camera Dialog
          var options = {
            quality: 100,
            destinationType: this.camera.DestinationType.FILE_URI,
            encodingType: this.camera.EncodingType.JPEG,
            sourceType: sourceType,
          };
          this.camera.getPicture(options).then((imagePath) => {
    // Special handling for Android library
            if (this.platform.is('android') && sourceType ===
              this.camera.PictureSourceType.PHOTOLIBRARY) {
              this.filePath.resolveNativePath(imagePath)
                .then(filePath => {
                  let correctPath = filePath.substr(0, filePath.lastIndexOf('/') + 1);
                  let currentName = imagePath.substring(imagePath.lastIndexOf('/') + 1,
                    imagePath.lastIndexOf('?'));
                  this.copyFileToLocalDir(correctPath, currentName, this.createFileName());
                  this.lastImage = filePath;
                });
            } else {
              var currentName = imagePath.substr(imagePath.lastIndexOf('/') + 1);
              var correctPath = imagePath.substr(0, imagePath.lastIndexOf('/') + 1);
              this.copyFileToLocalDir(correctPath, currentName, this.createFileName());
            }
          }, (err) => {
            this.presentToast('Error while selecting image.');
          });


        } catch (e) {
          console.error(e);
        }


      }

错误:不允许加载本地资源
安卓6.0.1

最佳答案

No Need To Downgrade just write this code.

private win: any = window;
    this.win.Ionic.WebView.convertFileSrc(path);

关于android - 不允许加载本地资源 : ionic 3 android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52055126/

相关文章:

java - 读取 jar 文件中的数据(Java 中)并对文件进行计数

perl - 如何使用 Perl 在目录及其所有子目录中找到最新的 .pl 文件?

java - 如何用Java获取Mac应用程序文件夹

java - 更改颜色选择器的大小

c - 如何在c中逐行读取?

java - 如何找到file.txt的最大和最小数字?

java - 如何读取文本文件的相对路径

javascript - 按下键盘完成按钮时,Focusout 不适用于移动设备,但适用于文档点击

android - 底部工具栏布局

android - 封装在 Android JNI 和 iOS 中的 C/C++ 应用示例