Skip to content

Instantly share code, notes, and snippets.

@dhavaln
Created July 3, 2012 10:25
Show Gist options
  • Save dhavaln/3038930 to your computer and use it in GitHub Desktop.
Save dhavaln/3038930 to your computer and use it in GitHub Desktop.
Cordova 1.7 Camera Test
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="lib/android/cordova-1.7.0.js"></script>
<script type="text/javascript" charset="utf-8">
var loaded = false;
function onPhotosLoad() {
alert("In the ONPHOTOLOAD JS");
// only load the camera selector on first load
if (!loaded) {
navigator.camera.getPicture(onPhotoLoadSuccess, onFail, {
quality : 50,
encodingType : Camera.EncodingType.PNG,
destinationType : navigator.camera.DestinationType.FILE_URI
});
loaded = true;
}
}
function onPhotoLoadSuccess(photoUri) {
alert("In the ONPHOTOLOADSUCCESS JS");
document.getElementById('photo').src = photoUri;
}
function onFail(message) {
alert('Failed because: ' + message);
}
document.addEventListener("deviceready",onDeviceReady,false);
function onDeviceReady() {
console.log("device is ready");
}
</script>
</head>
<body>
<button onclick="onPhotosLoad()">Take Photo</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment