[英]Cordova navigator.camera.getPicture returns FILE_URI in unexpected format on Android 4.4 KitKat from gallery
Before Kitkat navigator.camera.getPicture returned a Uri like this 在Kitkat navigator.camera.getPicture返回像这样的Uri之前
content://media/external/images/media/3951
. content://media/external/images/media/3951
。
In Kitkat however it returns a Uri like this: 但是在Kitkat中,它会返回如下Uri:
content://com.android.providers.media.documents/document/image:3951
Example code using cordova-2.9.0: 使用cordova-2.9.0的示例代码:
gallery: function () {
navigator.camera.getPicture(this.handleUri,
function () {
console.log('error retrieving imageURI');
return false;
},
{ quality: 100,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY }
);
},
handleUri: function (imageURI) {
//imageURI is in unexpected format content://com.android.providers.media.documents/document/image:3951
}
How do we return the URI in the original format? 我们如何以原始格式返回URI?
There is nothin wring with the URL. URL没什么用。
It is no file URL it is a Content-URL. 它不是文件URL,而是内容URL。 You should be able to work with that URL as well.
您也应该能够使用该URL。 If not, you may have to use a Content-Resolver .
如果不是,则可能必须使用Content-Resolver 。
What do you want to do with the URL? 您要如何处理网址? And what does note work?
笔记有什么用?
use destinationType: navigator.camera.DestinationType.DATA_URL instead of destinationType: navigator.camera.DestinationType.FILE_URI 使用destinationType:navigator.camera.DestinationType.DATA_URL代替destinationType:navigator.camera.DestinationType.FILE_URI
and add com.simplec.plugins.externalfiles plugin to your config.xml or 并将com.simplec.plugins.externalfiles插件添加到config.xml或
Update your Cordova to 3.5 this fixes all Kitkat issues 将您的Cordova更新至3.5,可以解决所有Kitkat问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.