来自Phonegap的联系人图像未显示

 花花花 发布于 2022-12-31 19:25

我看到几篇与此相关的文章,如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"

如何解决这个问题.请帮我.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有