Luban
Luban copied to clipboard
选择相册照片,传入uri,压缩后的file是没有的,file.length=0
同问题
作者自己用Uri.getPath了,这个path根本就不能用,只能download代码自己动刀
解决方案是什么?
Uri.getPath确实不能用,暂时将Uri转成了String用的
`
public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) { Cursor cursor = null; final String column = MediaStore.Images.Media.DATA; final String[] projection = {column}; try { cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null); if (cursor != null && cursor.moveToFirst()) { final int column_index = cursor.getColumnIndexOrThrow(column); return cursor.getString(column_index); } } catch (Exception ex) { ex.printStackTrace(); } finally { if (cursor != null) { cursor.close(); } } return null; } `