android - Integrated zxing and scan on demand -


i integrated qr code scanning feature in app using zxing source code library. activity extended capture activity , override handledecode method of capture activity class. code inside override method handledecode looks this:

@override public void handledecode(result rawresult, bitmap barcode){ string result = rawresult.gettext(); if(result==wrong_code){       //do nothing }else if(result==right_code){       //do    } } 

the idea pretty simple. if user scan correct code something, otherwise keep scanning until obtain correct code. however, problem zxing scanner scan once. if qr code returned wrong, user has restart activity in order scanner scan again.

i tried if result code wrong doesn't work.

hanlder handler = new handler(); handler.sendemptymessagedelayed(r.id.preview_id, captureactivity.bulk_mode_scan_delay_ms 

i had problem myself today, solved calling gethandler() instead of creating new handler when doing sendemptymessagedelayed. old question, suppose won't helping @ all, others same problem.. well, here's solution:

   @override     public void handledecode(result rawresult, bitmap barcode, float scalefactor) {             toast.maketext(this.getapplicationcontext(), "scanned code " + rawresult.gettext(), toast.length_long).show();               gethandler().sendemptymessagedelayed(r.id.restart_preview, 1000l);     } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -