Source:
<code>public void onResult(int requestCode, int resultCode, Intent data) { Timber.v("activity result..."); try { if (requestCode == REQUEST_IMAGE_CAPTURE) { Bitmap imageBitmap = null; if (resultCode == android.app.Activity.RESULT_OK) { Bundle extras = data.getExtras(); imageBitmap = (Bitmap) extras.get("data"); } if (onComplete != null) { onComplete.call(imageBitmap); } } else if (requestCode == PICK_PHOTO) { Bitmap imageBitmap = null; if (resultCode == android.app.Activity.RESULT_OK) { Uri imageUri = data.getData(); String imagePath = imageUri.getPath(); <START> if (!"com.android.providers.media.documents".equals(imageUri.getAuthority())) { <END> String extension = MimeTypeMap.getFileExtensionFromUrl(imageUri.getPath()); if (extension != null) { MimeTypeMap mime = MimeTypeMap.getSingleton(); String type = mime.getMimeTypeFromExtension(extension); if (!acceptedMimeTypes.contains(type)) { showError(getView().getActivity().getString(R.string.err_cant_load_photo_bad_extension)); return; } } else { showError(getView().getActivity().getString(R.string.err_cant_load_photo_bad_extension)); return; } } ParcelFileDescriptor parcelFileDescriptor = getView().getActivity().getContentResolver().openFileDescriptor(imageUri, "r"); FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor(); Bitmap image = BitmapFactory.decodeFileDescriptor(fileDescriptor); parcelFileDescriptor.close(); imageBitmap = Bitmap.createScaledBitmap(image, THUMBNAIL_MINI_WIDTH, THUMBNAIL_MINI_HEIGHT, false); } if (onComplete != null) { onComplete.call(imageBitmap); } } } catch (Exception e) { Timber.e(e, "Error loading image"); Crashlytics.logException(e); showError(getView().getActivity().getString(R.string.err_cant_load_photo)); } }</code><technical_language>min sdk is ICS. this PR works for ICS above</technical_language>

Target:
public void onResult(int requestCode, int resultCode, Intent data) { Timber.v("activity result..."); try { if (requestCode == REQUEST_IMAGE_CAPTURE) { Bitmap imageBitmap = null; if (resultCode == android.app.Activity.RESULT_OK) { Bundle extras = data.getExtras(); imageBitmap = (Bitmap) extras.get("data"); } if (onComplete != null) { onComplete.call(imageBitmap); } } else if (requestCode == PICK_PHOTO) { Bitmap imageBitmap = null; if (resultCode == android.app.Activity.RESULT_OK) { Uri imageUri = data.getData(); String imagePath = imageUri.getPath(); if (!("media".equals(imageUri.getAuthority()) && imageUri.getPath().startsWith("/external/images/media")) && (!"com.android.providers.media.documents".equals(imageUri.getAuthority()))) { String extension = MimeTypeMap.getFileExtensionFromUrl(imageUri.getPath()); if (extension != null) { MimeTypeMap mime = MimeTypeMap.getSingleton(); String type = mime.getMimeTypeFromExtension(extension); if (!acceptedMimeTypes.contains(type)) { showError(getView().getActivity().getString(R.string.err_cant_load_photo_bad_extension)); return; } } else { showError(getView().getActivity().getString(R.string.err_cant_load_photo_bad_extension)); return; } } ParcelFileDescriptor parcelFileDescriptor = getView().getActivity().getContentResolver().openFileDescriptor(imageUri, "r"); FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor(); Bitmap image = BitmapFactory.decodeFileDescriptor(fileDescriptor); parcelFileDescriptor.close(); imageBitmap = Bitmap.createScaledBitmap(image, THUMBNAIL_MINI_WIDTH, THUMBNAIL_MINI_HEIGHT, false); } if (onComplete != null) { onComplete.call(imageBitmap); } } } catch (Exception e) { Timber.e(e, "Error loading image"); Crashlytics.logException(e); showError(getView().getActivity().getString(R.string.err_cant_load_photo)); } }