我看到几篇与此相关的文章,如Ref,但不适合我.我尝试过如下
第一种方法:
从联系人图像值直接设置图像源
var myImg = document.getElementById("cimg"); myImg.src = contacts[i].photos[0].value;
这个没有在img标签中显示图像.
第二种方法:
将联系人图像值传递给fileDownload选项
window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, function(fs){ fs.root.getFile("temp.jpg", {create: true, exclusive: false}, function(entry){ //alert(entry.toURL()); var fileTransfer = new FileTransfer(); fileTransfer.download( contacts[i].photos[0].value, // the filesystem uri you mentioned entry.fullPath, function(entry) { // do what you want with the entry here console.log("download complete: " + entry.fullPath); var src = entry.fullPath; //$("").append(''); }, function(error) { alert("error source " + error.source); console.log("error target " + error.target); console.log("error code " + error.code); console.log(error); }, false, null ); }, function(e){ console.log("file create error",e); }); }, null);
这个显示错误 07-28 07:37:56.468: E/FileTransfer(20986): {"target":"file:\/\/\/mnt\/sdcard\/Android\/data\/io.cordova.hellocordova\/cache\/temp.jpg","http_status":0,"code":3,"source":"content:\/\/com.android.contacts\/contacts\/2\/photo","exception":"read failed: EINVAL (Invalid argument)"}
07-28 07:37:56.468: E/FileTransfer(20986): java.io.IOException: read failed: EINVAL (Invalid argument)
编辑:
我的phonegap 联系人[i] .photo [0] .value return like "content://com.android.contacts/contacts/1/photo"
如何解决这个问题.请帮我.