Note that there are some explanatory texts on larger screens.

plurals
  1. POPhoneGap: Application crash taking portrait picture
    text
    copied!<p>I am using jQuery Mobile and PhoneGap to create an app that allows users to take a picture, view it on screen, and then upload it to a server application that will ultimately post it on a website.</p> <p>This works well if I take the photo in Landscape mode, but crashes the application when I take a Portrait photo. As you can see from the code snippet below I am using the correctOrientation parameter to attempt to orient the photo after it is taken. Without this parameter the application doesn't crash, however the photo is in the wrong orientation when it gets displayed.</p> <p>Right now I'm testing this on Sony XPERIA android phone.</p> <p>Here is the code responsible for the work.</p> <pre><code>function onPhotoFail(message) { alert('Failed because: ' + message); } function onPhotoSuccess(imageURI) { var $image = $("img#upload-image"); $image.attr("src", imageURI); } function capturePhoto() { navigator.camera.getPicture(onPhotoSuccess, onPhotoFail, { quality: 50, destinationType: Camera.DestinationType.FILE_URI , correctOrientation: true }); } </code></pre> <p>Here's the stack trace:</p> <pre><code>E/AndroidRuntime(31760): FATAL EXCEPTION: main E/AndroidRuntime(31760): java.lang.OutOfMemoryError: bitmap size exceeds VM budget E/AndroidRuntime(31760): at android.graphics.Bitmap.nativeCreate(Native Method) E/AndroidRuntime(31760): at android.graphics.Bitmap.createBitmap(Bitmap.java:477) E/AndroidRuntime(31760): at android.graphics.Bitmap.createBitmap(Bitmap.java:444) E/AndroidRuntime(31760): at org.apache.cordova.CameraLauncher.getRotatedBitmap(CameraLauncher.java:483) E/AndroidRuntime(31760): at org.apache.cordova.CameraLauncher.onActivityResult(CameraLauncher.java:326) E/AndroidRuntime(31760): at org.apache.cordova.DroidGap.onActivityResult(DroidGap.java:823) E/AndroidRuntime(31760): at android.app.Activity.dispatchActivityResult(Activity.java:3908) E/AndroidRuntime(31760): at android.app.ActivityThread.deliverResults(ActivityThread.java:2549) E/AndroidRuntime(31760): at android.app.ActivityThread.handleSendResult(ActivityThread.java:2595) E/AndroidRuntime(31760): at android.app.ActivityThread.access$2000(ActivityThread.java:121) E/AndroidRuntime(31760): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:973) E/AndroidRuntime(31760): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime(31760): at android.os.Looper.loop(Looper.java:130) E/AndroidRuntime(31760): at android.app.ActivityThread.main(ActivityThread.java:3701) E/AndroidRuntime(31760): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime(31760): at java.lang.reflect.Method.invoke(Method.java:507) E/AndroidRuntime(31760): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) E/AndroidRuntime(31760): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624) E/AndroidRuntime(31760): at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>I've done some searching around, and I don't see anybody having this exact problem. Any help is appreciated</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload