Phonegap 1.7 barcode reader crash

138 views
Skip to first unread message

mf

unread,
Jun 6, 2012, 1:21:51 AM6/6/12
to eclipse-plugi...@googlegroups.com
Hi guys,

could you please help me. I'm newbie in phonegap world.
I have an application that using the barcode reader plugin.
It works well until after scanning the code.
After I scan the code there is a message show at the bottom of the screen :

"Found URL"

then it give "Application Error"

"The web page containts an error. (File:///android_asset/www/scanQR/#)"

this is script that I use to call the scan method :

var scanCode = function() {
    window.plugins.barcodeScanner.scan(
        function(result) {
        alert("Scanned Code: " + result.text 
                + ". Format: " + result.format
                + ". Cancelled: " + result.cancelled);
    }, function(error) {
        alert("Scan failed: " + error);
    });
}

I call it by :

<a href="#" data-role="button" onclick="scanCode();">Scan Code</a>

and you can see my androidManifest.xml in attachment.

Please help me, I tried several ways before like update *.java and change the screen orientation,
but it doesn't work.

Thank You.
AndroidManifest.xml

Libby

unread,
Jun 6, 2012, 8:08:42 PM6/6/12
to eclipse-plugi...@googlegroups.com
I am able to scan and encode using cordova 1.8 and
the latest barcode scanner plugin.

The problem may be related to whatever you have here:
"The web page containts an error. (File:///android_asset/www/scanQR/#)"
And how your pages are structured. What is scanQR/# ?
Is it trying to change pages? Try adding console.log in the
success and fail callbacks to see how far the scan is getting.

Attached is my AndroidManifest.xml that was created using the
tutorial, nothing extra added. Not sure if you've created a verified
a vanilla app, like the tutorial, before adding extra stuff.

Cheers,
Libby
AndroidManifest.xml

mf

unread,
Jun 6, 2012, 10:49:59 PM6/6/12
to eclipse-plugi...@googlegroups.com
Hi Libby,

Thank you so much for your reply.
I found the mistake, and it is a newbie error

I should return to the original page in <a href>, like this :

<a href="#page" data-role="button" onclick="scanCode();">Scan Code</a>

instead of 

<a href="#" data-role="button" onclick="scanCode();">Scan Code</a>

it works well.

Thank you so much Libby and phone gap.
GBU.

Morgan_...@hotmail.com

unread,
Sep 29, 2013, 5:12:23 AM9/29/13
to eclipse-plugi...@googlegroups.com

The BarcodeScanner plugin is now available on PhoneGap Build!  But my multi-orientation phonegap app, keeps automatic changing orientation even when the barcode scanner is up (scanning) this is really useless, because now you have to rotate the box you want to scan, instead of just tilting your mobile device. Now my question is:
Is there some way to prevent the barcode scanner window from changing orientation? 


Reply all
Reply to author
Forward
0 new messages