WebScan is an Android application which adds barcode scanning to a web browser. A request to scan can be made via a JavaScript call.
The browser functionality is provided via the standard Android WebKit widget. This version of WebScan is missing some convenience features you would expect to find in the standard browser. These will be added as time permits.
The barcode scanner functionality is provided via the (free) ZXing application. If you don't already have this installed (it's bundled on some phones) you'll be prompted and sent to the marketplace to get it. This feature was taken from some example code found at the ZXing site.
Call this JavaScript function:
window.WebScan.scanThenLoadURL('[SCANVALUE]')
Because scans are a bit asynchronous theres not a simple get() function at this time.
This is very much version 1.
The argument you pass to scanThenLoadURL() is a string. On a sucessful scan, the scanned value is replaced in that string at [SCANVALUE] and the browser attempts to load the result. If you know you're scanning URLs then [SCANVALUE] is a sensible argument to pass. If you're looking up things in Google then "http://google.com/search?q=[SCANVALUE]" would make sense.
If you want to do something more clever then use the javascript URL scheme and call a function of your own:
<input type="button" value="Scan"
onClick="window.WebScan.scanThenLoadURL('javascript:myCleverFunction(\'[SCANVALUE]\')');" />
Other browsers don't have this JavaScript call and you probably don't want to show a scan button for them in any case. Here's one technique for resolving that (assumes you use jQuery). The page you're reading now uses this technique.
Step one: add webscan class to things that scan:
<input type="button" value="Scan"
class="webscan"
onClick="window.WebScan.scanThenLoadURL('javascript:myCleverFunction(\'[SCANVALUE]\')');" />
Step two: turn off items w/ webscan class if we're not in the WebScan browser
$(function(){
if (typeof(window.WebScan) == "undefined" ) {
$('.webscan').hide();
}
});
You might choose instead to invert the logic and hide by default. You'd want to set display:none for the
webscan class in your style sheet and invert the Step two behaviour.
I detect that you are not viewing this using WebScan so no examples for you but you could view the source of this page.
I detect that you are viewing this using WebScan so here's some examples
(here)