我正在读这样的位图。我正在挑选画廊中的选择并获得例外。请帮我解决这个问题。
// Read bitmap
public Bitmap readBitmap(Uri selectedImage) {
Bitmap bm = null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 5;
AssetFileDescriptor fileDescriptor =null;
try {
fileDescriptor = this.getContentResolver().openAssetFileDescriptor(selectedImage,"r");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
finally{
try {
bm = BitmapFactory.decodeFileDescriptor(fileDescriptor.getFileDescriptor(), null, options);
fileDescriptor.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return bm;
}
记录跟踪:
06-13 14:05:11.470: W/System.err(20799): java.io.FileNotFoundException: No such file or directory
06-13 14:05:11.470: W/System.err(20799): at android.os.Parcel.openFileDescriptor(Native Method)
06-13 14:05:11.470: W/System.err(20799): at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:117)
06-13 14:05:11.480: W/System.err(20799): at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:609)
06-13 14:05:11.480: W/System.err(20799): at com.example.Main.readBitmap(Main.java:416)
06-13 14:05:11.480: W/System.err(20799): at com.example.Main.addContents(Main.java:315)
06-13 14:05:11.480: W/System.err(20799): at com.example.Main.sendMMS(Main.java:231)
06-13 14:05:11.480: W/System.err(20799): at com.example.Main.access$16(Main.java:228)
06-13 14:05:11.480: W/System.err(20799): at com.example.Main$AsyncNetworkOperation.doInBackground(Main.java:397)
06-13 14:05:11.490: E/Trace(23274): error opening trace file: No such file or directory (2)
06-13 14:05:11.490: D/ActivityThread(23274): setTargetHeapUtilization:0.25
06-13 14:05:11.490: D/ActivityThread(23274): setTargetHeapIdealFree:8388608
06-13 14:05:11.490: D/ActivityThread(23274): setTargetHeapConcurrentStart:2097152