forked from github/cordova-android
Camera plugin (HTC Incredible) is crashing on 2.3.4 devices without SD card
This commit is contained in:
parent
ccdd2fd2ca
commit
b9ddc9e678
@ -35,6 +35,7 @@ import org.json.JSONArray;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.ContentResolver;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
@ -289,6 +290,17 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
// If sending base64 image back
|
// If sending base64 image back
|
||||||
if (destType == DATA_URL) {
|
if (destType == DATA_URL) {
|
||||||
bitmap = getScaledBitmap(FileUtils.stripFileProtocol(imageUri.toString()));
|
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) {
|
if (rotate != 0 && this.correctOrientation) {
|
||||||
bitmap = getRotatedBitmap(rotate, bitmap, exif);
|
bitmap = getRotatedBitmap(rotate, bitmap, exif);
|
||||||
@ -567,6 +579,9 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
options.inJustDecodeBounds = false;
|
options.inJustDecodeBounds = false;
|
||||||
options.inSampleSize = calculateSampleSize(options.outWidth, options.outHeight, this.targetWidth, this.targetHeight);
|
options.inSampleSize = calculateSampleSize(options.outWidth, options.outHeight, this.targetWidth, this.targetHeight);
|
||||||
Bitmap unscaledBitmap = BitmapFactory.decodeFile(imagePath, options);
|
Bitmap unscaledBitmap = BitmapFactory.decodeFile(imagePath, options);
|
||||||
|
if (unscaledBitmap == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return Bitmap.createScaledBitmap(unscaledBitmap, widthHeight[0], widthHeight[1], true);
|
return Bitmap.createScaledBitmap(unscaledBitmap, widthHeight[0], widthHeight[1], true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user