From f3a704b59dbe43af6c54912e05d2e2bfb1a4ebd8 Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Mon, 24 Feb 2014 14:30:28 -0500 Subject: [PATCH] CB-1826 Android: Guard against content provider not supplying orientation --- src/android/CameraLauncher.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/android/CameraLauncher.java b/src/android/CameraLauncher.java index d4ba168..57878ab 100755 --- a/src/android/CameraLauncher.java +++ b/src/android/CameraLauncher.java @@ -534,14 +534,18 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect } private int getImageOrientation(Uri uri) { - String[] cols = { MediaStore.Images.Media.ORIENTATION }; - Cursor cursor = cordova.getActivity().getContentResolver().query(uri, - cols, null, null, null); int rotate = 0; - if (cursor != null) { - cursor.moveToPosition(0); - rotate = cursor.getInt(0); - cursor.close(); + String[] cols = { MediaStore.Images.Media.ORIENTATION }; + try { + Cursor cursor = cordova.getActivity().getContentResolver().query(uri, + cols, null, null, null); + if (cursor != null) { + cursor.moveToPosition(0); + rotate = cursor.getInt(0); + cursor.close(); + } + } catch (Exception e) { + // You can get an IllegalArgumentException if ContentProvider doesn't support querying for orientation. } return rotate; }