Reputation: 75
Ok here is the deal I did everything on here I also add the code to the manifest taking care is inside the and add the permisions also edit the xml file located at my res folder... then create a com/phonegap/plugins/barcodescanner
and add the BArcodeScanner.java file to it. Them inport to my html <script src="barcodescanner.js"> </script>
that is located on the same directory as the html...
Here is the html code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Validacion de usuarios</title>
<link rel="stylesheet" href="css/decoracion.css" />
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/jquery.mobile-1.3.1.min.js"></script>
<script src="barcodescanner.js"></script>
</head>
<body>
<div data-role="page" id="inicio">
<div data-role="header">
<h1>Autenticacion de Usuario</h1>
</div>
<div data-role="content">
<input type="button" onclick="scanCode();" value="SCAN">
</div>
</div>
<script>
function scanCode() {
alert("ENTRA");
window.plugins.barcodeScanner.scan( function(result) {
alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
}, function(error) {
alert("Scanning failed: " + error);
}
);};
</script>
</body>
</html>
The problem comes when I press the button I know that it enters the function but it doesn't open the camara or anything just stay there. Is that suppost to happend? anyone can point me in the right direction. Thanks a lot.
Upvotes: 2
Views: 1360
Reputation: 75
I was really dumb and didn't import the barcodescanner.js to the html file
Upvotes: 3