我正在从相机和直接从画廊拍摄的列表视图中加载图片。在来自画廊的模拟器图像上工作完美。但是在设备上,当我选择第一张图片时效果很好。但是当我第二次选择同一张图片时,应用程序崩溃并且没有出现 logcat。这是一个代码:
if (requestCode == UploadFile && resultCode == RESULT_OK && null != data) {
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
Bitmap image=(BitmapFactory.decodeFile(picturePath));
cursor.close();
addattachmentsToListView(image);