简体   繁体   English

Cordova navigator.camera.getPicture在Android 4.4 KitKat上以意外格式返回FILE_URI

[英]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.

相关问题 cordova navigator.camera.getPicture 在 android 中不起作用 - cordova navigator.camera.getPicture not working in android 画廊错误中的navigator.camera.getPicture错误“无法创建位图” - navigator.camera.getPicture from the gallery error “Unable to create bitmap” navigator.camera.getPicture在android中不起作用 - navigator.camera.getPicture not working in android 为什么我不能在Android应用中使用Cordova 2.7.0触发navigator.camera.getPicture? - Why can't I trigger navigator.camera.getPicture using Cordova 2.7.0 in my Android app? Cordova 3.4.0 navigator.camera.getPicture不会为Android 4.3回调onSuccess或onFail - Cordova 3.4.0 navigator.camera.getPicture does not callback onSuccess or onFail for Android 4.3 Cordova 3.4.0:从GALLERY中选择时,Camera.getPicture()返回编码的URI - Cordova 3.4.0: Camera.getPicture() returns encoded URI when selected from GALLERY navigator.camera.getPicture无法正常工作 - navigator.camera.getPicture not working properly navigator.camera.getPicture不会调用成功回调 - 离子框架 - cordova - navigator.camera.getPicture doesn’t call success callback - ionic framework - cordova ionic navigator.camera.getPicture不会从PHOTOLIBRARY返回图像 - ionic navigator.camera.getPicture won't return image from PHOTOLIBRARY Android 4.4 (KitKat) 上的 Android Gallery 为 Intent.ACTION_GET_CONTENT 返回不同的 URI - Android Gallery on Android 4.4 (KitKat) returns different URI for Intent.ACTION_GET_CONTENT
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM