根据返回的uri获得图片真实路径
public static Uri convertFileUri(Context mContext, Uri uri) {
String filePath;
if (uri != null && "content".equals(uri.getScheme())) {
Cursor cursor = mContext
.getContentResolver()
.query(uri,
new String[] { android.provider.MediaStore.Images.ImageColumns.DATA },
null, null, null);
cursor.moveToFirst();
filePath = cursor.getString(0);
cursor.close();
} else {
filePath = uri.getPath();
}
return Uri.parse("file://" + filePath);
}
接收返回值
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != RESULT_OK) { return; }
if (requestCode == PICK_PICTURE_RESUMABLE) {
doUpload(data.getData());
return;
}
}
调用系统图库
Intent i = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);startActivityForResult(i, PICK_PICTURE_RESUMABLE);