Starting the android zxing scanner via web app doesn't seem to work

My starting point for scanning from a web app was this article here Then i realized it was as simple as clicking a link like this

http://zxing.appspot.com/scan?req=http%3A%2F%2FLOCAL_SERVER_NAME%2FMY_APP_NAME%2FMY_SERVLET%3Fcode%3D%7BCODE%7D

but it didn't work.

My web app is simple like this (using ajax from jquery)

$("#onebutton").click(function(){
        $.ajax({
            url: "http://zxing.appspot.com/scan",
            success:function(){
                alert("success");
            },
            error:function(){
                alert("error");
            },
            data:{
                req:"http%3A%2F%2F192.168.1.100:8080%2FMY_APP_NAME%2FMY_SERVLET%3Fcode%3D%7BCODE%7D"
            }

        });
    });

needless to say that "#onebutton" is a button tag with that id. When Pressing such button on a browser in android it always alerts the error message. It doesn't ask for the scanner to start up. When i click the button in a normal PC, the console says:

"Origin http://192.168.1.100:8080 is not allowed by Access-Control-Allow-Origin".

Am i doing something wrong?. Am i missing something?

Thank you all in advance!!

Answers


I dont know if you fully understand purpose of link.

Try to add to

Access-Control-Allow-Origin on server

Or

$("#onebutton").click(function(){
        $.ajax({
            url: "http://zxing.appspot.com/scan?ret=http%3A%2F%2F192.168.1.100:8080%2FMY_APP_NAME%2FMY_SERVLET%3Fcode%3D%7BCODE%7D",
            success:function(){
                alert("success");
            },
            error:function(){
                alert("error");
            }

        });
    });

but you propably dont understand

<a href="zxing://scan/?ret=http%3A%2F%2Ffoo.com%2Fproducts%2F%7BCODE%7D%2Fdescription&SCAN_FORMATS=UPC_A,EAN_13"> ads </a>

This is serve to open zxing scanner get some code information and replace it in the given url after it is open like

.../scan!ret=www.host.com/product_{code}.hmtl

after scan it open web browser with

http://www.host.com/product_123.html


You should use a link like this to open the scanner:

<a href="zxing://scan/?ret=http://something.com/yourpage$status={CODE}"> 
    <span>My scan</span>
</a>

Please, pay attention that in my example $status is a variable which takes the value of the scanned barcode. This passes the value as a parameter in the address of the page it is leading to.

I see that the thread is a bit old, but I hope this will help someone.


Need Your Help

Read and write from a socket simultaneously

java android multithreading sockets

I'm writing an android app in java and I want to create a listener that receive messages in a while(true) loop, and also to be able to send messages to the server.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.