Samsung Galaxy S3 ships with "Do not keep Activities" on by default (test models in two locations were both having this fault out the box)
Of course this means that as soon as any other activity is started, including from within your Cordova/PhoneGap app, your app's main activity will be destroyed. Any callback events will obviously never fire.
Switching the option off fixes the problem.
Check developer options regardless of brand/model, for example Asus Nexus 7 tablets do not have this default.
I've setup a basic test app. Which has a button and an img tag + the unmodified Cordova index.js
Button onclick is calling capturePhoto()
:
function onPhotoURISuccess(imageURI) {
console.log(imageURI);
var largeImage = document.getElementById('largeImage');
largeImage.style.display = 'block';
largeImage.src = imageURI;
}
function capturePhoto() {
navigator.camera.getPicture( onPhotoURISuccess, onFail,
{ quality: 20, allowEdit: true, destinationType: Camera.DestinationType.FILE_URI });
}
function onFail(message) {
alert('Failed because: ' + message);
}
When I run the app on the simulator and also on a Asus Nexus 7 Tablet, the Camera opens as expected, allows a photo to be taken and confirmed, and then returns with the FILE_URI and sets the image src
attribute.
However on a Samsung Galaxy SIII, (we are testing with two in different locations) the Camera opens, allows a capture, and after confirmation, attempts to resume the test app and dies.
Does anyone know of this problem, and is there a way to fix it?
FYI, I've added an extra setting to the AndroidManifest.xml
activity node : android:screenOrientation="nosensor"
- although this doesn't solve the issue (clutching at straws here.)
Tested versions of phonegap - 1.8 - 2.4rc (all crash or fail to return image.)
Relevant portion of the stacktrace is here: http://pastie.org/5974920
Tested with quality : 100
Same results as before.
None working.
On the Samsung Galaxy 3 the developer option Do not keep activities is on by default.
This will garbage collect your main activity when you launch any other, in this case the Camera.
Switching off the option solves the problem.
I have a Samsung Galaxy Note II. I had the same problem. I changed this in the AndroidManifest.xml and now it works on Samsung and HTC Thunderbolt
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="10"/>
<activity android:configChanges="orientation|keyboardHidden" />
Do you have background processes turned off? If so, this will break ALL Android cameras. The data being passed back in the intent can't be null.
Also, be certain to add this to your Android Manifest:
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
The fact that 2.4.x crashes is a bug, since something broke that handled the resume state in this case, but the fact is that you need background processes to pass the data from one intent to another, otherwise this won't work with any Android application. We at least start to gracefully handle this case. The app closing I think may be a bug, so I'd be interested in seeing a ticket here: https://issues.apache.org/jira/browse/CB
Update: See https://issues.apache.org/jira/browse/CB-2533
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With