从图库上载图像到Rest API时,在旧的Android设备上可以正常工作。图像完美上传到服务器。但是,当我使用新的Android Pie设备上传图片时,则不会上传图片。
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && data != null) {
Uri SelectedImage = data.getData();
filePath = (String) getRealPathFromUri(getActivity(),data.getData());
photoFile = new File(filePath);
img_image.setImageURI(SelectedImage);
}
}