PictureSelector
PictureSelector copied to clipboard
封装了一个函数 能完美获取真实文件路径兼容各种机型
Current use version?
当前使用的版本是多少?3.11.2
Will this problem occur in demo?
Demo能否复现这问题?
Describe the problem or provide an error log?
描述问题或提供错误log?
3.11.2的版本 fun getPath2(context: Context, localMedia: LocalMedia): String? { val path = localMedia.path ?: localMedia.realPath return if (!path.isNullOrEmpty() && path.startsWith("content://")) { val uri = Uri.parse(path) PictureFileUtils.getPath(context, uri) } else { path } }
String path = "";
if (!TextUtils.isEmpty(media.getCompressPath())) {
path = media.getCompressPath();
} else {
if (!TextUtils.isEmpty(media.getPath()) && media.getPath().startsWith("content:")) {
Uri uri = Uri.parse(media.getPath());
path = PictureFileUtils.getPath(context, uri);
} else {
path = media.getRealPath();
}
}