目录

相册选择图片缩略图不显示

问题现象

从相册选择图片上传预览时不展示缩略图。

背景知识

问题定位

通过日志排查图片加载报错信息,发现显示GetAsset failed,可知图片路径不对。

04-19 15:34:30.062 25379 26202 W C03900/Ace: [(100000:100000:scope)] GetAsset failed: data/storage/el2/base/cache/a835451856dd41b588ad31d86b51ee31.jpg
04-19 15:34:30.062 25379 26202 W C0391F/AceImage: [(100000:100000:scope)] No asset data! NodeId = 761-759.
04-19 15:34:30.062 25379 26202 W C0391F/AceImage: [(100000:100000:scope)] Fail load imageData. src = <private>, nodeId = 761-759.
04-19 15:34:30.062 25379 25379 I C03945/AceStateStyle: [(100000:100000:scope)] Start execution, node is Text/766, reset is 1
04-19 15:34:30.062 25379 25379 I C03945/AceStateStyle: [(100000:100000:scope)] Find customNode from parent: Button2
04-19 15:34:30.063 25379 25379 W C0391F/AceImage: [(100000:100000:scope)] Image LoadFail, source = <private>, reason: Failed to load image data

分析结论

data/storage/el2/base/是沙箱路径,直接使用而未转换为系统可识别的URI,导致图片不显示。

修改建议

选择相册图片,将文件保存到应用沙箱目录后,将路径转换成系统可识别的URI显示。