The only previous question I found concerning my problem is this one: Android app reverts back to index page after taking a picture
But it doesn't really answer, and my Manifest has this on the main Activity tag :
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
I'm writing a PhoneGap 2.8.1 app with jQueryMobile 1.3.1 on Android and I encounter a (not so) annoying rendering issue.
I call the camera.getPicture
feature of PhoneGap like this :
capturePicture: function() {
navigator.camera.getPicture(
app.onCameraSuccess,
app.onCaptureError,
{ quality : 50,
destinationType : Camera.DestinationType.DATA_URL,
sourceType : Camera.PictureSourceType.CAMERA,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 250,
targetHeight: 250,
saveToPhotoAlbum: false
}
);
},
And retrieve Base64 encoded image like so :
onCameraSuccess: function( b64EncodedImage ) {
var imageEncoded = "data:image/jpeg;base64," + b64EncodedImage;
$('div.accred_pic_preview')
.fadeOut()
.css('backgroundImage', 'url("' + imageEncoded + '")')
.fadeIn()
// The accred_pic_input is hidden, so I must call trigger event manually
$("#accred_pic_input").val( imageEncoded ).trigger("change");
app.goTo("accred"); // <== I must manually go to jQueryMobile page ID
}
Everything goes fine, but when returning to app, webView reloads (or refreshes) content.
EDIT: That part is confusing, let's forget it
The problem is that I trigger change event on an hidden input to activate the submit button when my required inputs are OK. And as you can see below, I must manually go to previous active page with a function of mine, so the change event is not fired when manually changing page (the change is already effective when I finally arrive on the target page)
EDIT thanks to Robin C Samuel for clearing my mind When capture OK (by the native android photo app), focus is given back to my app. At that moment, my app being a JQM/PhoneGap combination, the webView part of the app is refreshed, so that the defaut (index) JQM page is shown before I programatically go to the page calling the capture plugin, containing my form.
I want to avoid that behaviour, and going back directly to the page calling the capture plugin, after capture OK.
Does anyone know a way to force PhoneGap's webView not to refresh content after a capture?