Skip to content Skip to sidebar Skip to footer

How To Integrate Barcode Scanner In Phonegap In Android Platform?

I want to integrate a 'barcodescanner'-feature into my PhoneGap Application, but facing problem while running my app 'class not found or applicationcontent is missing in applicatio

Solution 1:

I just tested it and works fine :

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="msapplication-tap-highlight" content="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" />
</head>
<body>

<button onclick="scanBarcode()">Scan</button>

    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
    <script>
    function scanBarcode(){

cordova.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 issue with your code is that you don't have functions scan() and encode() to bind to your buttons thus nothing will happen.


Solution 2:

What is your version of Phonegap and the version of the plugin? Is your barcodescanner.js well loaded?

Do you have this permissions in your manifest:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />

Post a Comment for "How To Integrate Barcode Scanner In Phonegap In Android Platform?"