[ https://issues.apache.org/jira/browse/CB-5567?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13944715#comment-13944715 ]
Zhang Hong commented on CB-5567: -------------------------------- i've got same issue with 3.4.0-0.1.3 s4 4.2.2 genymotion nexus7 emu 4.4.2 > Phonegap (3.2.0 and 3.1.0) Camera not successful on first try > ------------------------------------------------------------- > > Key: CB-5567 > URL: https://issues.apache.org/jira/browse/CB-5567 > Project: Apache Cordova > Issue Type: Bug > Components: Android > Affects Versions: 3.1.0, 3.2.0 > Environment: Windows 7 32bit, Eclipse. CLI Phonegap 3.2.0 > Reporter: engr > Labels: features > > Phonegap (3.2.0 and 3.1.0) Camera not successful on first try. even after the > second capture try nothing shown to the screen but after the third capture > try it show the captured picture. > Kindly find the below code which i am using: > <!DOCTYPE html> > <html> > <head> > <title>Capture Photo</title> > <script type="text/javascript" charset="utf-8" src="cordova.js"></script> > <script type="text/javascript" charset="utf-8"> > var pictureSource; // picture source > var destinationType; // sets the format of returned value > // Wait for device API libraries to load > // > document.addEventListener("deviceready",onDeviceReady,false); > // device APIs are available > // > function onDeviceReady() { > pictureSource=navigator.camera.PictureSourceType; > destinationType=navigator.camera.DestinationType; > } > // Called when a photo is successfully retrieved > // > function onPhotoDataSuccess(imageData) { > // Uncomment to view the base64-encoded image data > // console.log(imageData); > > alert("1"); > // Get image handle > // > var smallImage = document.getElementById('smallImage'); > // Unhide image elements > // > smallImage.style.display = 'block'; > // Show the captured photo > // The inline CSS rules are used to resize the image > // > smallImage.src = "data:image/jpeg;base64," + imageData; > } > // Called when a photo is successfully retrieved > // > function onPhotoURISuccess(imageURI) { > // Uncomment to view the image file URI > // console.log(imageURI); > // Get image handle > // > var largeImage = document.getElementById('largeImage'); > // Unhide image elements > // > largeImage.style.display = 'block'; > // Show the captured photo > // The inline CSS rules are used to resize the image > // > largeImage.src = imageURI; > } > // A button will call this function > // > function capturePhoto() { > alert("capturePhoto"); > // Take picture using device camera and retrieve image as > base64-encoded string > navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 10, > destinationType: destinationType.DATA_URL }); > alert("2"); > onPhotoDataSuccess(imageData); > } > // A button will call this function > // > function capturePhotoEdit() { > // Take picture using device camera, allow edit, and retrieve image as > base64-encoded string > navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 20, > allowEdit: true, > destinationType: destinationType.DATA_URL }); > } > // A button will call this function > // > function getPhoto(source) { > // Retrieve image file location from specified source > navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, > destinationType: destinationType.FILE_URI, > sourceType: source }); > } > // Called if something bad happens. > // > function onFail(message) { > alert("Failed"); > } > </script> > </head> > <body> > <button onclick="capturePhoto();">Capture Photo565</button> <br> > <button onclick="capturePhotoEdit();">Capture Editable Photo</button> <br> > <button onclick="getPhoto(pictureSource.PHOTOLIBRARY);">From Photo > Library</button><br> > <button onclick="getPhoto(pictureSource.SAVEDPHOTOALBUM);">From Photo > Album</button><br> > <img style="display:none;width:60px;height:60px;" id="smallImage" src="" > /> > <img style="display:none;" id="largeImage" src="" /> > </body> > </html> -- This message was sent by Atlassian JIRA (v6.2#6252)