You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2012/11/13 23:31:43 UTC
[4/4] android commit: Camera plugin (HTC Incredible) is crashing on
2.3.4 devices without SD card
Camera plugin (HTC Incredible) is crashing on 2.3.4 devices without SD card
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/b9ddc9e6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/b9ddc9e6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/b9ddc9e6
Branch: refs/heads/master
Commit: b9ddc9e678e5fdaca6a49fbfaea5e375ac4c3871
Parents: ccdd2fd
Author: Iurii Okhmat <iu...@inrix.com>
Authored: Fri Nov 9 16:40:56 2012 -0800
Committer: Iurii Okhmat <iu...@inrix.com>
Committed: Fri Nov 9 16:40:56 2012 -0800
----------------------------------------------------------------------
.../src/org/apache/cordova/CameraLauncher.java | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/b9ddc9e6/framework/src/org/apache/cordova/CameraLauncher.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CameraLauncher.java b/framework/src/org/apache/cordova/CameraLauncher.java
index f9cfb94..0dc02a4 100755
--- a/framework/src/org/apache/cordova/CameraLauncher.java
+++ b/framework/src/org/apache/cordova/CameraLauncher.java
@@ -35,6 +35,7 @@ import org.json.JSONArray;
import org.json.JSONException;
import android.app.Activity;
+import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
@@ -289,6 +290,17 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
// If sending base64 image back
if (destType == DATA_URL) {
bitmap = getScaledBitmap(FileUtils.stripFileProtocol(imageUri.toString()));
+ if (bitmap == null) {
+ // Try to get the bitmap from intent.
+ bitmap = (Bitmap)intent.getExtras().get("data");
+ }
+
+ // Double-check the bitmap.
+ if (bitmap == null) {
+ Log.d(LOG_TAG, "I either have a null image path or bitmap");
+ this.failPicture("Unable to create bitmap!");
+ return;
+ }
if (rotate != 0 && this.correctOrientation) {
bitmap = getRotatedBitmap(rotate, bitmap, exif);
@@ -567,6 +579,9 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
options.inJustDecodeBounds = false;
options.inSampleSize = calculateSampleSize(options.outWidth, options.outHeight, this.targetWidth, this.targetHeight);
Bitmap unscaledBitmap = BitmapFactory.decodeFile(imagePath, options);
+ if (unscaledBitmap == null) {
+ return null;
+ }
return Bitmap.createScaledBitmap(unscaledBitmap, widthHeight[0], widthHeight[1], true);
}