Scanner QRCode (Zxing) with PhoneGap 1.2.0 (Android 2.3.3)

2,351 views
Skip to first unread message

Zarlok

unread,
Nov 12, 2011, 7:56:46 AM11/12/11
to phonegap
Someone can tell me how I can put 1 reader QR to me application? I use
phoneGap 1.2.0 and I already started with my project. I just need put
the code reader to me project, but I can't know how do it.

Please, someone can tell me step for step? The tutorial plugin
phonegap don't understand...

ALEX NG

unread,
Nov 12, 2011, 9:02:28 AM11/12/11
to phonegap

Zarlok

unread,
Nov 12, 2011, 9:07:01 AM11/12/11
to phonegap
The first step say:

1- Add the 'LibraryProject' into Eclipse. File -> New Android Project -
> create project from existing source.

I need the scannerQRCODE for my project. If I create another project
is useless. The scanning will not be able to put in my project.

Thank you for answering but I do not know what to do.




On 12 nov, 15:02, ALEX NG <alexn...@gmail.com> wrote:
> do you tryhttps://github.com/phonegap/phonegap-plugins/tree/master/Android/Barc...

Paul Beusterien

unread,
Nov 12, 2011, 10:31:52 AM11/12/11
to phon...@googlegroups.com
Libby recently updated the MDS Barcode Scanner step-by-step tutorial here.

Zarlok

unread,
Nov 12, 2011, 11:05:41 AM11/12/11
to phonegap
Very very very thanks!! =) But she take a project, i just need the
scan and within with me project. Now I try, if I have problems notify
you.

On 12 nov, 16:31, Paul Beusterien <paul.beuster...@gmail.com> wrote:
> Libby recently updated the MDS Barcode Scanner step-by-step tutorial here<http://www.mobiledevelopersolutions.com/home/start/twominutetutorials...>
> .

Simon MacDonald

unread,
Nov 12, 2011, 11:21:06 AM11/12/11
to phon...@googlegroups.com
Zarlock,

Follow the tutorial. You put the barcode scanning code into a library
project so it can be used from multiple applications. Part of the
tutorial will show you how to reference the library project from your
applications project. If you follow all the steps you will be fine.

Simon Mac Donald
http://hi.im/simonmacdonald

> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com
>

Zarlok

unread,
Nov 12, 2011, 1:51:51 PM11/12/11
to phonegap
Hi! Simon!!! You have reason. No appear any error. But when I do: Run -
> Run As ... ------> Blank screen appears. (I've placed
well .js, .jar and libraries.)

index.html :
<!DOCTYPE HTML>
<html>
<head>
<title>QR</title>
<link rel="stylesheet" type="text/css" href="estilos/css3button.css" /
>
<script type="text/javascript" charset=”utf-8?
src="phonegap-1.2.0.js"></script>
<script type="text/javascript" src="barcodescanner.js"></script>
</head>
<body>
<script>
window.plugins.barcodeScanner.encode(BarcodeScanner.Encode.TEXT_TYPE,
"http://www.nytimes.com", function(success) {
alert("encode success: " + success);
}, function(fail) {
alert("encoding failed: " + fail);
}
);
</script>
</body>
</html>





On 12 nov, 17:21, Simon MacDonald <simon.macdon...@gmail.com> wrote:
> Zarlock,
>
> Follow the tutorial. You put the barcode scanning code into a library
> project so it can be used from multiple applications. Part of the
> tutorial will show you how to reference the library project from your
> applications project. If you follow all the steps you will be fine.
>
> Simon Mac Donaldhttp://hi.im/simonmacdonald

Simon MacDonald

unread,
Nov 12, 2011, 3:26:29 PM11/12/11
to phon...@googlegroups.com
It is because you are not waiting for the "deviceready" event.

Simon
--

Zarlok

unread,
Nov 12, 2011, 3:56:43 PM11/12/11
to phonegap
appear error (when click the button):

Alert: Scan failed: No activity found to handle Intent
{act=com.phonegap.plugins.barcodescanner.SCAN
cat=[android.intent.category.DEFAULT]}




index.html:

...
<script type="text/javascript" charset=”utf-8?
src="phonegap-1.2.0.js"></script>
<script type="text/javascript" src="barcodescanner.js"></script>
</head>

<body>


<script>


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);
});
}
</script>


<a href="#" class="btn" onclick="scanCode();">Scan Code</a>

</body>
</html>

Simon MacDonald

unread,
Nov 12, 2011, 7:05:47 PM11/12/11
to phon...@googlegroups.com
Sounds like you did not add the activities to your AndroidManifest.xml as was described in the readme.

Simon

On Saturday, November 12, 2011, Zarlok <euseb...@gmail.com> wrote:

Eusebi Vidal

unread,
Nov 12, 2011, 7:07:41 PM11/12/11
to phon...@googlegroups.com

I did it... And emulate with my galaxy s2. Is very strange

Zarlok

unread,
Nov 13, 2011, 7:08:54 AM11/13/11
to phonegap
This appear in AndroidManifest.xml to "LibraryProject"

<!-- versionCode is a monotonically increasing integer. I'm starting
it at 6 because v2.3 is the 6th
version to be published. The next versionCode will be 7, regardless of
whether the user-visible
versionName is 2.31, 2.4, or 3.0. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.zxing.client.android"
android:versionName="3.61 beta 1"
android:versionCode="71"
android:installLocation="auto">
<!-- We require Cupcake (Android 1.5) or later, but are really
targeting Donut. -->
<uses-sdk android:minSdkVersion="3"
<-----------------------------------------------------------------------------------
In my project I use 2.3.3 (10) if I put 10 it does not work
android:targetSdkVersion="4"/>
<!-- Donut-specific flags which allow us to run on any dpi screens.
-->
<supports-screens android:xlargeScreens="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>




PD: I put this in AndroidManifest to my project:
<!-- ZXing activities --> <activity
android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden"> <intent-filter>
<action android:name="com.phonegap.plugins.barcodescanner.SCAN"/>
<category android:name="android.intent.category.DEFAULT"/> </intent-
filter> </activity> <activity
android:name="com.google.zxing.client.android.encode.EncodeActivity"
android:label="@string/share_name"> <intent-filter> <action
android:name="com.phonegap.plugins.barcodescanner.ENCODE"/> <category
android:name="android.intent.category.DEFAULT"/> </intent-filter> </
activity>

Zarlok

unread,
Nov 13, 2011, 10:45:53 AM11/13/11
to phonegap
It's work!!! Thank you for all!!!!!
You had reason!! xD!!!

I put:

<!-- ZXing activities --> <activity
android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden"> <intent-filter>
<action android:name="com.phonegap.plugins.barcodescanner.SCAN"/>
<category android:name="android.intent.category.DEFAULT"/> </intent-
filter> </activity> <activity
android:name="com.google.zxing.client.android.encode.EncodeActivity"
android:label="@string/share_name"> <intent-filter> <action
android:name="com.phonegap.plugins.barcodescanner.ENCODE"/> <category
android:name="android.intent.category.DEFAULT"/> </intent-filter> </
activity>



</application> <-----but i don't put it

</manifest>
Reply all
Reply to author
Forward
0 new messages