ScanResult and ConnectionRequest problem

62 views
Skip to first unread message

anop...@gmail.com

unread,
Jan 9, 2014, 12:07:53 PM1/9/14
to codenameone...@googlegroups.com
My app needs to scan a QR code and depending on its contents it invokes a different web service.

I'm using the ScanCompleted method below:
CodeScanner.getInstance().scanQRCode(new ScanResult() {
public void scanCompleted(String contents, String formatName, byte[] rawBytes) {
Log.p("scanCompleted");

if(contents.equals("22")) {
flag = "22";
Hashtable tab = getJsonResponseHashtable(ip, "os_jme2");
applyServerSettings(tab);

Display.getInstance().callSerially(new Runnable() {
public void run() {
showForm("Main", null);
}
});
}
}
}


 
The strange thing is that the JsonResponseHashtable(...) and the applyServerSettings(...) methods seem to never getting called! 
(I have put some Log.p() messages in order to check that). 
In the JsonResponseHashtable I open a new ConnectionRequest().

Any ideas what is going wrong?

Shai Almog

unread,
Jan 9, 2014, 2:21:46 PM1/9/14
to codenameone...@googlegroups.com, anop...@gmail.com
I suggest printing out the contents to see what went wrong.

anop...@gmail.com

unread,
Jan 10, 2014, 6:12:20 AM1/10/14
to codenameone...@googlegroups.com, anop...@gmail.com
For your convenience I'm attaching my code (ScanResult() which is scanning the QR code and getJsonResponseHashtable() which is calling my service) and the cn1.log file.
The contents of the QR code is "22" (text) but I don't think there is a problem with reading it. 

There is a strange behaviour in general when scanning the QR code. Please follow the Log.p() statements and you 'll understand what I'm talking about..

Thank you
cn1_log.txt
getJsonResponseHashtable.txt
ScanResult.txt

Shai Almog

unread,
Jan 10, 2014, 2:21:45 PM1/10/14
to codenameone...@googlegroups.com, anop...@gmail.com
I'm guessing your code in scanCompleted is triggering an exception which is causing the scan error to be invoked. I suggest wrapping it in try/catch.

anop...@gmail.com

unread,
Jan 21, 2014, 6:58:42 AM1/21/14
to codenameone...@googlegroups.com, anop...@gmail.com
I've added a try/catch block in my scanCompleted method. however, this method does not seem to trigger any kind of exceptions.

No matter what I scan I can see that after getting in the scanCompleted() method I'm always getting to the scanCancelled() method and sometimes to the scanError() method (usually after the scanCanceled()).

Any ideas?

Shai Almog

unread,
Jan 21, 2014, 2:40:54 PM1/21/14
to codenameone...@googlegroups.com, anop...@gmail.com
On which platform is this happening to you?

anop...@gmail.com

unread,
Jan 28, 2014, 9:37:25 AM1/28/14
to codenameone...@googlegroups.com, anop...@gmail.com
Sorry for my late answer... It's on J2ME platform Shai!

Shai Almog

unread,
Jan 28, 2014, 3:31:39 PM1/28/14
to codenameone...@googlegroups.com, anop...@gmail.com
With J2ME I'm really unsure. This code was contributed to us and frankly its a bit of a black box. Maybe Chen can wager a guess.

anop...@gmail.com

unread,
Jan 29, 2014, 4:14:54 AM1/29/14
to codenameone...@googlegroups.com, anop...@gmail.com
Chen what r ur thoughts on this?

anop...@gmail.com

unread,
Feb 10, 2014, 9:51:09 AM2/10/14
to codenameone...@googlegroups.com, anop...@gmail.com
When Scan is successfully completed I always get a "java.lang.IllegalStateException: Player is CLOSED." in my log file..
Is this a bug?

Shai Almog

unread,
Feb 10, 2014, 12:51:51 PM2/10/14
to codenameone...@googlegroups.com, anop...@gmail.com
In which platform?
Do you have a stack trace?

anop...@gmail.com

unread,
Feb 11, 2014, 5:26:42 AM2/11/14
to codenameone...@googlegroups.com, anop...@gmail.com
Platform is J2ME. I don't have the stacktrace as I'm not a PRO user. 

Shai Almog

unread,
Feb 11, 2014, 11:52:37 AM2/11/14
to codenameone...@googlegroups.com, anop...@gmail.com
That's a problem for us to debug. The J2ME code for scanner is an unmaintained ZXing port that was contributed to us.
Reply all
Reply to author
Forward
0 new messages