注册

Android本地图片路径获取失败

PathUtil.getInstance().getImagePath().getAbsolutePath()返回null
这个情况怎么解决?
已邀请:
提示String path = PathUtil.getInstance().getImagePath() + "/" + imageName; 空指针 PathUtil.getInstance().getImagePath()为null,不知道是什么问题
和手机环境有没有关系?目标 获取图片下载后的路径并显示。

lzan13 - 慢慢来,一步一个脚印?

路径的拼接是根据远程url地址,解析除文件名,然后前边加上getImagePath的路径,不需要获取绝对路径了
 public static String getImagePath(String remoteUrl) {
String imageName = remoteUrl.substring(remoteUrl.lastIndexOf("/") + 1, remoteUrl.length());
String path = PathUtil.getInstance().getImagePath() + "/" + imageName;
EMLog.d("msg", "image path:" + path);
return path;

}

要回复问题请先登录注册