问题描述
我正在使用7.0.1版的cordova和2.4.1版的cordova-plugin-camera.navigator.camera.getPicture(successFunction,failureFunction,options)在选项中,我使用
I am using cordova version 7.0.1 and the cordova-plugin-camera version 2.4.1.navigator.camera.getPicture(successFunction, failureFunction,options)In the options, I use
destinationType: Camera.DestinationType.FILE_URI
sourceType: Camera.PictureSourceType.PHOTOLIBRARY
我正确获取了图像URI.我创建一个"img"元素,并将img.src设置为插件返回的URI.图片正确显示.现在,我将此URI存储在应用程序的本地文件夹中,然后关闭该应用程序.我重新启动应用程序,并从存储中读取imageURI.然后,创建一个"img"元素,并将img.src设置为URI读取形式存储.
I am getting the image URI correctly.I create a "img" element and set the img.src to the URI returned by the pluginThe picture appears correctly.Now, I store this URI in the application's local folder, and close the application.I restart the application, and read the imageURI from storage.Then, I create an "img" element and set the img.src to the URI read form storage.
从存储中读取的URI与之前由相机插件getPicture()调用返回的URI相同.但是,图像文件未读取,并且图片未出现在屏幕上.我看到的错误是无法打开内容URL:
The URI read from storage is identical to the URI earlier returned by the camera plugin getPicture() call.But, the image file is not read and the picture does not appear on screen. The errors I am seeing areUnable to open content URL:
因此,我认为这是一个白名单问题.我加了进入config.xml文件.但这会使应用程序在尝试读取图像文件时崩溃.
So, I thought this was a whitelist problem. I addedinto the config.xml file. But this makes the app crash when it tries to read the image file.
我正在运行Android棉花糖的Karbonn手机上尝试此操作.
I am trying this on a Karbonn phone running Android Marshmallow.
如果您知道以上所述有什么问题,请在此分享解决方案.
Please do share the solution if you know what is wrong with the above, what else I need to do here.
推荐答案
似乎在不使用像摄像头这样的某些系统应用"的情况下,从诸如图库之类的媒体商店"访问图像时,普通应用必须拥有权限android.permission.MANAGE_DOCUMENTS
才能访问该图像.
It seems when accessing an image from a "media-store" like the gallery without using "a certain system-app" like the camera, an ordinary app must hold the permission android.permission.MANAGE_DOCUMENTS
in order to have access to that image.
不幸的是,普通应用没有此权限,如答案所述.因此,必须使用保留android.permission.MANAGE_DOCUMENTS
权限的系统应用程序"将图库图像移动/复制到应用程序文件夹(file:///storage/emulated/0/Android/data/APP_NAMESPACE
)中,以便普通应用程序在重新启动后可以显示该图像例如.
Unfortunately ordinary apps do not have this permission, as this answer says. Therefore a gallery-image must be moved/copied into the app-folder (file:///storage/emulated/0/Android/data/APP_NAMESPACE
) by using "a system-app" that holds the android.permission.MANAGE_DOCUMENTS
-permission so that an ordinary app can show this image after a it was restarted for instance.
这篇关于重新启动应用程序后,cordova无法打开相机插件返回的fileURL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!