Scan barcodes from a mobile web site?
As nothing seems to come out, I'll explain the best solution I found.
The thing is to use the app "pic2shop". It is a barcode scanning app that is available on Android, iOS and Windows Phone 8.
It is possible to request this app from a web page, let it scan the barcode and then callback you web site with the scanned information.
window.location="pic2shop://scancallback=http%3A//www.google.com/m/
products%3Fgl%3Dus%26source%3Dmog%26hl%3Den%26source%3Dgp
2%26q%3DEAN%26btnProductsHome%3DSearch%2BProducts
The above example will open the app and when the user scans a barcode, open the web browser on a google search for the scanned product barcode.
If pic2shop is not installed on the phone, the call will fail. The thing is to set a timeout that will redirect to the store (to download the app) if the call fails.
User agents can be used to know to which store it should redirect.
Full example (Android store redirection) :
<SCRIPT LANGUAGE="JavaScript">
function trygoogle() {
setTimeout(function() {
// if pic2shop not installed yet, go to App Store
window.location = "market://details?id=com.visionsmarts.pic2shop";
}, 25);
// launch pic2shop and tell it to open Google Products with scan result
window.location="pic2shop://scan?callback=http%3A//www.google.com/m/products%3Fgl%3Dus%26source%3Dmog%26hl%3Den%26source%3Dgp2%26q%3DEAN%26btnProductsHome%3DSearch%2BProducts";
}
</SCRIPT>
Documentation : http://www.pic2shop.com/developers.html
Android barcode scanner integration with web page
Using a javascript interface and loadurl(javascript...) you can communicate with your webpage from Android
public void loadScript(String script){
webview.loadUrl("javascript:(function() { " + script + "})()");
}
private class JavaScriptInterface {
public void startQRScan() {
...
}
}
There are plenty of examples on google.
Scanning barcode in Desktop-Browser using mobile
If you want to use an Android device camera, you don't need to connect the device to the USB port. Not like a webcam, there's no driver for opening Android camera straightforward on PC.
A possible workaround:
- Use WebSocket for communication between the desktop browser (E.g. desktop.htm) and the mobile browser (E.g. mobile.htm).
- Use WebRTC (getUserMedia) to open Android camera in the mobile browser.
- Embed a JavaScript barcode SDK (E.g. ZXing or Dynamsoft JavaScript Barcode SDK) into your mobile web app.
- Read barcodes and sync results from mobile.htm to desktop.htm via WebSocket.
Use integrate barcode scanner with Xamarin Forms
I found an issue to my problem.
In my xaml file
<Entry x:Name="myEntry"
Unfocused="Entry_Unfocused" />
In my c# file
private void Entry_Unfocused(object sender, FocusEventArgs e)
{
this.myEntry.Focus()
}
Related Topics
How to Detect Overflow of React Component Without Reactdom
Vue.Js Refs Are Undefined, Even Though This.$Refs Shows Theyre There
How to Load a Font File in Vuejs and Webpack
How to Hide Blinking Cursor in Input Text
Javascript Onclick Increment Number
How to Validate for Only CSV File Uploads Using the Pattern Attribute Using Html5
415 (Unsupported Media Type) With Rest Post Request
Angular 6 Store Data from Json Array Inside Json
When Click on Menu, It Opens, When Click Again It Close
How to Highlight a Part of Text in Textarea
How to I Retrieve Last Part of Url and Use It in HTML
Check If a Key Exists Inside a Json Object
Detect Click into Iframe Using JavaScript
Array Map into String With Line Break - React
Mongodb, Update Collection Field If New Value Is Not Null