Created
July 31, 2013 23:04
-
-
Save filmaj/6127003 to your computer and use it in GitHub Desktop.
Off the ground with cordova camera in no time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="format-detection" content="telephone=no" /> | |
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> | |
<link rel="stylesheet" type="text/css" href="css/index.css" /> | |
<title>Hello World</title> | |
</head> | |
<body> | |
<div class="app"> | |
<h1>Apache Cordova</h1> | |
<div id="deviceready" class="blink"> | |
<p class="event listening">Connecting to Device</p> | |
<p class="event received">Device is Ready</p> | |
</div> | |
<button onclick="snap();">SNAP A PICTURE DUDE!</button> | |
<img id="image" src="" /> | |
</div> | |
<script type="text/javascript" src="cordova.js"></script> | |
<script type="text/javascript" src="js/index.js"></script> | |
<script type="text/javascript"> | |
app.initialize(); | |
function snap() { | |
navigator.camera.getPicture(function(pic_path) { | |
document.getElementById('image').src = pic_path; | |
}, | |
function(message) { alert('get picture failed'); }, | |
{ | |
quality: 50, | |
destinationType: navigator.camera.DestinationType.FILE_URI, | |
sourceType: navigator.camera.PictureSourceType.CAMERA | |
}); | |
} | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cordova create tmp | |
cd tmp | |
cordova platform add android | |
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git | |
vim www/index.html | |
cordova run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment