java - detector.isOperational() always false on android -


i'm using new google plays service: barcode detector, porposue i'm following tutorial : https://search-codelabs.appspot.com/codelabs/bar-codes

but when run application on real device(asus nexus 7), text view of app showing me "couldn't set detector" , don't know how make work >< ...

here code fast debugging:

public class decoderbar extends activity implements view.onclicklistener{  private textview  txt; private imageview img;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.layout_decoder);      button b = (button) findviewbyid(r.id.button);     txt = (textview) findviewbyid(r.id.txtcontent);     img = (imageview) findviewbyid(r.id.imgview);      b.setonclicklistener(this); }  // [...]  @override public void onclick(view v) {      bitmap mybitmap = bitmapfactory.decoderesource(getapplicationcontext().getresources(),r.drawable.popi);     img.setimagebitmap(mybitmap);      barcodedetector detector = new barcodedetector.builder(getapplicationcontext())             .setbarcodeformats(barcode.data_matrix | barcode.qr_code)             .build();      if(!detector.isoperational()){         // show message, so, never operational!         txt.settext("could not set detector!");         return;     }      frame frame = new frame.builder().setbitmap(mybitmap).build();     sparsearray<barcode> barcodes = detector.detect(frame);      barcode thiscode = barcodes.valueat(0);     txt.settext(thiscode.rawvalue); } } 

it looks first time barcode detector used on each device, download done google play services. here link:

https://developers.google.com/vision/multi-tracker-tutorial

and excerpt:

the first time app using barcode and/or face apis installed on device, gms download libraries device in order barcode , face detection. done installer before app run first time.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -