diff --git a/src/android/CameraLauncher.java b/src/android/CameraLauncher.java old mode 100755 new mode 100644 index 6d80f73..64d185b --- a/src/android/CameraLauncher.java +++ b/src/android/CameraLauncher.java @@ -380,14 +380,19 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect else if (destType == FILE_URI || destType == NATIVE_URI) { if (this.saveToPhotoAlbum) { Uri inputUri = getUriFromMediaStore(); - //Just because we have a media URI doesn't mean we have a real file, we need to make it - uri = Uri.fromFile(new File(FileHelper.getRealPath(inputUri, this.cordova))); + try { + //Just because we have a media URI doesn't mean we have a real file, we need to make it + uri = Uri.fromFile(new File(FileHelper.getRealPath(inputUri, this.cordova))); + } catch (NullPointerException e) { + uri = null; + } } else { uri = Uri.fromFile(new File(getTempDirectoryPath(), System.currentTimeMillis() + ".jpg")); } if (uri == null) { this.failPicture("Error capturing image - no media storage found."); + return; } // If all this is true we shouldn't compress the image. @@ -735,11 +740,11 @@ private String ouputModifiedBitmap(Bitmap bitmap, Uri uri) throws IOException { Uri uri; try { uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); - } catch (UnsupportedOperationException e) { + } catch (RuntimeException e) { LOG.d(LOG_TAG, "Can't write to external media storage."); try { uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values); - } catch (UnsupportedOperationException ex) { + } catch (RuntimeException ex) { LOG.d(LOG_TAG, "Can't write to internal media storage."); return null; }