android - Getting value of scanning at Motorola TC55 -


i want scan barcode in app. start scan not know how detect scanned value. code looks like

public class myfragment extends fragment {     @override     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {         return inflater.inflate(r.layout.pick, container, false);     }      @override     public void onviewcreated(view view, bundle savedinstancestate) {         super.onviewcreated(view, savedinstancestate);          // scan         this.getactivity().findviewbyid(r.id.scan).setonclicklistener(new onclicklistener() {              @override             public void onclick(view view) {                 // start scanner in example:  https://developer.motorolasolutions.com/docs/doc-1874#programming%20interface                    intent intent = new intent();                 intent.setaction("com.motorolasolutions.emdk.datawedge.api.action_softscantrigger");                 intent.putextra("com.motorolasolutions.emdk.datawedge.api.extra_parameter", "toggle_scanning");                 view.getcontext().sendorderedbroadcast(intent, null, receiver, null, 0, null, null);             }         });     }      private broadcastreceiver receiver = new broadcastreceiver() {          @override         public void onreceive(context context, intent intent) {             // how detect scanned value???                }     } } 

i solve it. code.

intent intent = new intent(); intent.setaction("com.motorolasolutions.emdk.datawedge.api.action_softscantrigger"); intent.putextra("com.motorolasolutions.emdk.datawedge.api.extra_parameter", "toggle_scanning"); getactivity().sendbroadcast(intent);  getactivity().registerreceiver(new broadcastreceiver() {      @override             public void onreceive(context context, intent intent) {                         string code = intent.getextras().getstring("com.motorolasolutions.emdk.datawedge.data_string");          //          getactivity().unregisterreceiver(this);     } } , new intentfilter("myintentaction")); 

the profile in datawedge has enable output via intent , disable keystroke output. intent action set string same "myintentaction". scanned barcode directly in fragment after scanning.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -