From a29340523fa9abf73cbab83676b397c27b7519d3 Mon Sep 17 00:00:00 2001 From: Simon MacDonald Date: Fri, 7 Sep 2012 15:20:31 -0400 Subject: [PATCH] CB-1293: Camera.getPicture crashes when selecting from a Picasa album on Android --- .../src/org/apache/cordova/CameraLauncher.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/framework/src/org/apache/cordova/CameraLauncher.java b/framework/src/org/apache/cordova/CameraLauncher.java index 0e79c5df..a72de6af 100755 --- a/framework/src/org/apache/cordova/CameraLauncher.java +++ b/framework/src/org/apache/cordova/CameraLauncher.java @@ -388,12 +388,19 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie } else { // Get the path to the image. Makes loading so much easier. String imagePath = FileUtils.getRealPathFromURI(uri, this.cordova); - // If we don't have a valid image path quit. + Log.d(LOG_TAG, "Real path = " + imagePath); + // If we don't have a valid image so quit. if (imagePath == null) { - this.failPicture("Unable to retreive picture!"); + Log.d(LOG_TAG, "I either have a null image path or bitmap"); + this.failPicture("Unable to retreive path to picture!"); return; } Bitmap bitmap = getScaledBitmap(imagePath); + if (bitmap == null) { + Log.d(LOG_TAG, "I either have a null image path or bitmap"); + this.failPicture("Unable to create bitmap!"); + return; + } if (this.correctOrientation) { String[] cols = { MediaStore.Images.Media.ORIENTATION }; @@ -456,8 +463,10 @@ public class CameraLauncher extends Plugin implements MediaScannerConnectionClie this.success(new PluginResult(PluginResult.Status.OK, uri.toString()), this.callbackId); } } - bitmap.recycle(); - bitmap = null; + if (bitmap != null) { + bitmap.recycle(); + bitmap = null; + } System.gc(); } }