Umer Pasha Blogs

Simplest Phonegap Barcode reader example

Created a small app last night to read barcodes.


Nothing fancy. Just a button to invoke the barcode reader camera and then returns the barcode number along with the barcode standard.


You can get it here:



Checked on iPhone 5S and Android Kit Kat.


I am only using an html file and a js file along with the config.xml.


You can get the code from my github repository. You can remove the resource files from config.xml. I just got it from the base template.




  1. To add the plugin , in Config.xml you need to have:

<gap:plugin name=”com.phonegap.plugins.barcodescanner”/>


  1. Write the following javascript to listen for an event (button click) and then start the scanner


</p><p>var resultDiv;</p><p> </p><p>document.addEventListener("deviceready", init, false);</p><p>function init() {</p><p>               
 document.querySelector("#startScan").addEventListener("touchend", startScan, false);</p><p>               
 resultDiv = document.querySelector("#results");</p><p>}</p><p> </p><p>function startScan() {</p><p> </p><p>               
 cordova.plugins.barcodeScanner.scan(</p><p>                               function(result) {</p><p>                                               
 var s = "Result: " + result.text + "&lt;br/&gt;" +</p><p>                                               "Format: " + result.format + "&lt;br/&gt;" +</p><p>                                               "Cancelled: " + result.cancelled;</p><p>                                               
 resultDiv.innerHTML = s;</p><p>                               
 },</p><p>                               function(error) {</p><p>                                               
 alert("Scanning failed: " + error);</p><p>                               
 }</p><p>               );</p><p> </p><p>}</p><p> </p><p>







Microsoft announcing Windows 8 Mobile and abandoning its current users!

Announcing Windows 8 Mobile!

Wow! Talk about M$ screwing their users! Thankfully, I resisted staying away from Windows Phone. I know people who just got the Nokia Lumia…. and are now holding an obsolete device which is not upgrade-able to Win 8! and just a few days back I was complimenting M$ on their current streak of wise decisions…… looks like they are back with a vengeance 😛

SD card support? really? I have my android loaded with a 64GB card…. Win Mobile still supports 16GB??? really??? in this day and age??? To the cloud indeed!

720p?? Does that actually matter??? Its the pixel density that matters on smaller screens, not the resolution. No mention of pixel density.

Add to that…. a feeble app store missing all great apps and holding only 100K apps (out of which only 5% or so are worth a while…. forget even a penny price!) That is it I guess….. the death of Windows Mobile as a contender for one of top 3 Mobile OS…. and along with that they will take Nokia down!

Leave a comment »