为什么即使imageUri不为null或空,Parcel File Descriptor也会抛出FileNotFounException。我已经使用Intent从我的图库中选择了一个文件。我也为"imageUri“的价值干杯,它打印出来。
ParcelFileDescriptor percelFileDescriptor;
Toast.makeText(getApplicationContext(),""+imageUri.toString(),Toast.LENGTH_LONG).show();
try {
percelFileDescriptor = getContentResolver().openFileDescriptor(imageUri, "r");
image = BitmapFactory.decodeFileDescriptor(percelFileDescriptor.getFileDescriptor());
modified_img_bitmap = image;
percelFileDescriptor.close();
picked_image.setImageBitmap(image);
} catch (FileNotFoundException e) {
System.out.println("File Not Found: " + e.toString());
Toast.makeText(getApplicationContext(),"File not found: "+e.toString(),Toast.LENGTH_LONG).show();
} catch (IOException e) {
Toast.makeText(getApplicationContext(),"IO Error: "+e.toString(),Toast.LENGTH_LONG).show();
System.out.println("IO Exception: " + e.toString());
}
}https://stackoverflow.com/questions/41374898
复制相似问题