Re: Incompatible changes? ZXing/Android no longer works

322 views
Skip to first unread message

Sean Owen

unread,
Oct 22, 2012, 2:37:28 AM10/22/12
to zx...@googlegroups.com
Nothing has changed here in a long time, about a year. Have a look at diffs in SVN. The above looks correct.

Are you sure that another app is not interfering? Many apps that copy and paste the source code end up responding to the Intents and doing something totally wrong with them.
Or, maybe you have inadvertently copied these declarations and your own app is interfering.

Satz Klauer

unread,
Oct 22, 2012, 5:13:58 AM10/22/12
to zx...@googlegroups.com
So...can somebody confirm it is still working on an Android device
with latest code from Playstore?
> --
>
>
>

Sean Owen

unread,
Oct 22, 2012, 5:40:24 AM10/22/12
to zx...@googlegroups.com, satzk...@googlemail.com
Yes, try the ZXingTest app, which integrates by Intent and is kind of a test app. I built it from latest source just now and it works fine. Note that, for example, no result bytes are returned for a UPC code, since there is no byte representation. But it never has.

Satz Klauer

unread,
Nov 27, 2012, 9:03:54 AM11/27/12
to zx...@googlegroups.com, Sean Owen
OK, I have to come back to this issue: meanwhile I have feedback from
several users of my Android App telling me that ZXing no longer works!

For an example: they scan an EAN/UPC code and get back the information
"Product found". This message seems to be delivered by ZXing since my
app does not have such a text. And that's all, my calling App does not
get back any information (as described earlier in this thread).

So I guess there IS a problem - but I don't know what could be wrong
on my side when I use the original helper classes and code as
recommended...

Satz Klauer

unread,
Nov 27, 2012, 9:44:54 AM11/27/12
to Sean Owen, zx...@googlegroups.com
I afraid there is something I do not understand: I'm using
IntentReceiver and IntentIntegrator exactly as described within the
comment in head at
http://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentIntegrator.java

Shouldn't this code be correct? Or: what other code should I use to
get correct results from ZXing in case the access method describe
there is broken? And it definitely seems to be broken when
onActivityResult() returns immediately after calling initiateScan()
and with an empty IntentResult!?

So it is nice when the test app works but I need a way to implement
access to ZXing within an own app!

On Tue, Nov 27, 2012 at 3:05 PM, Sean Owen <sro...@gmail.com> wrote:
> The integration code hasn't changed in ages. I doubt there is any
> issue there. If the ZxingTest app works, then that pretty much
> demonstrates it. You can use it as a model. But I would definitely
> look to your handling of the reply and think about corner cases and
> weird code paths that you may not handle.

Lachezar Dobrev

unread,
Nov 27, 2012, 9:51:37 AM11/27/12
to Satz Klauer, Sean Owen, zx...@googlegroups.com
You are not using Fragments, are you?

2012/11/27 Satz Klauer <satzk...@googlemail.com>:
> --
>
>
>

Satz Klauer

unread,
Nov 28, 2012, 1:29:51 AM11/28/12
to Lachezar Dobrev, zx...@googlegroups.com
To clarify that (since the original posting is quite old): My app makes use of ZXing barcode scanner using the ZXing helper classes IntentIntegrator and IntentResult, no other things are used because it has to be compatibl with API version 7:

I'm using the latest helper classes from http://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentIntegrator.java and http://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentResult.java

Using them my onActivityResult method is called immediately after ZXing is started - of course with an empty result again. When ZXing finishes reading the barcode (much later), no more results are sent back to my app.

My code is quite simple (and copied out of the inline documentation of the IntentIntegrator), scanning is started this way:

   if (v==scanButton)
   {
      com.google.zxing.integration.android.IntentIntegrator integrator = new IntentIntegrator(this);
      integrator.initiateScan();
   }

...and fetching the results this way:

   public void onActivityResult(int requestCode, int resultCode, Intent intent)
   {
      com.google.zxing.integration.android.IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
      if (scanResult != null)
      {
         String format;

         format=scanResult.getFormatName();
         if ((format!=null) && (format.length()>0))
         {
            if ((format.equals("EAN_8")) || (format.equals("EAN_13")) ||(format.equals("UPC_A")) ||(format.equals("UPC_E")))
            getEANData(scanResult.getContents());
         }  
      }
   }    

On my android the latest ZXing code from Google Playstore is installed.

On Wed, Nov 28, 2012 at 7:08 AM, Satz Klauer <satzk...@googlemail.com> wrote:
> @Lachezar: what fragments?

Sean Owen

unread,
Nov 28, 2012, 4:21:29 AM11/28/12
to zx...@googlegroups.com, Lachezar Dobrev, satzk...@googlemail.com
I've written you a few times about this. Again, this part looks fine. You've said that you find scanResult is null, and I said that's normal -- the user cancelled the activity and you need to handle this. 

Satz Klauer

unread,
Nov 28, 2012, 1:20:57 PM11/28/12
to Sean Owen, zx...@googlegroups.com, Lachezar Dobrev
Sean,

so let me explain the problem again: the user did NOT cancel the operation! When I test it in debugger  the order is this:

- my app starts ZXing via IntentIntegrator
- ZXing starts
- onActivityResult IMMEDIATELY returns an IntentResult
- ZXing is still in foreground
- the user scans a barcode in ZXing
- now noting is returned to my app, onActivityResult is not called again.

When executing my app outside of the debugger it looks very similar, once ZXing has finished scanning the barcode my app does not get any results.

And in both cases the operation was not cancelled!

Sean Owen

unread,
Nov 28, 2012, 1:25:25 PM11/28/12
to zx...@googlegroups.com, Sean Owen, Lachezar Dobrev, satzk...@googlemail.com
This also happens if another Intent is received by the app for another reason. You can look at the request code to figure that out for sure. "null" means either it is not an intent from the scanner, or that the intent was cancelled (request code or result code doesn't match).

Sean Owen

unread,
Nov 28, 2012, 1:28:20 PM11/28/12
to zx...@googlegroups.com, Sean Owen, Lachezar Dobrev, satzk...@googlemail.com
Actually, change that -- it is only null when the reply is from another unrelated app. If it were cancelled you would get a non-null result with null fields. So it must be that the app is receiving some other unrelated Intent too. You can print the request code just to be sure. For scanning it is 0x0000c0de (49374).

Satz Klauer

unread,
Nov 28, 2012, 1:58:35 PM11/28/12
to Sean Owen, zx...@googlegroups.com, Lachezar Dobrev
OK, assumed this intent is received from somewhere else: why do I not receive the correct intent from ZXing as soon as it finishes? In get exactly ONE result immediately after ZXing was started - and that's all, nothing more can be received.

Beside of that: the code I'm using worked for a long time without any modifications, this strange behaviour is something that is new for some weeks...month.

Sean Owen

unread,
Nov 28, 2012, 2:29:50 PM11/28/12
to Satz Klauer, ZXing, Lachezar Dobrev
I don't know, are you sure you don't?

Right now we have a test app that works, a hundred apps integrating
this way that work, and you're repeatedly saying your app just doesn't
work. I strongly suspect it is something subtle in your app, right?

Are you sure this isn't being intercepted by another app which has
cloned barcode scanner? In which case the test app ought to have a
similar problem.

Satz Klauer

unread,
Dec 1, 2012, 11:57:33 AM12/1/12
to Sean Owen, zx...@googlegroups.com, Lachezar Dobrev
OK, ich checked that and the IntentResult of this way too early received intent is: 49374 (resultCode: 0, intent: null).

And to repeat that other fact: This app worked fine for a long time without ANY changes on the app itself. But after some updates of ZXing I and many other users of this app ran into this bug (with the original IntentIntegrator class the behaviour was a bit different but the received data have been null there too).

Sean Owen

unread,
Dec 1, 2012, 12:04:52 PM12/1/12
to Satz Klauer, ZXing, Lachezar Dobrev
That's the right request code, meaning it comes from this app (or
someone's clone of this app). Result code 0 means cancelled. Whatever
is registered to handle this is setting this result. The real app only
does this if you press Back.

Have you ruled out other apps on the phone registered to handle this
intent? you didn't put that in your manifest I hope.

From here, you need to read the source code and debug if you think
there's still a problem, and come back with something more specific. I
have no other reports of this from anyone else.

Satz Klauer

unread,
Dec 2, 2012, 5:08:01 AM12/2/12
to Sean Owen, ZXing, Lachezar Dobrev
No, there is nothing of this kind in my manifest.

Meanwhile I have downloaded and integrated the sources - can you give me a hint where the intent result is emitted from?

Sean Owen

unread,
Dec 2, 2012, 8:19:48 AM12/2/12
to Satz Klauer, ZXing, Lachezar Dobrev
The manifest points the intent to CaptureActivity, this is where to
look. Activity implementations will handle Intents in onResume(). Look
for references to "NATIVE_APP_INTENT" to trace the handling path.
Reply all
Reply to author
Forward
0 new messages