Scan With Soft And Hard Trigger

// Expert user has replied.
E Efkan YILMAZ 3 years 4 months ago
17 1 0

Hi,
 
We have a custom scanner, which works with SOFT trigger (used emdk library).
 
barcodeManager = (BarcodeManager) this.emdkManager.getInstance(EMDKManager.FEATURE_TYPE.BARCODE); scanner = barcodeManager.getDevice(BarcodeManager.DeviceIdentifier.DEFAULT); scanner.addStatusListener(articleListener); scanner.addDataListener(new Scanner.DataListener() {     @Override     public void onData(ScanDataCollection scanDataCollection) {         processData(scanDataCollection);     } }); scanner.addDataListener(dataListener); scanner.triggerType = Scanner.TriggerType.SOFT_ALWAYS; scanner.enable();  
but how can i have both soft and Hard trigger to scan the data?
and with datalistener process the data received from both?

Please Register or Login to post a reply

1 Replies

P Pietro Francesco Maggi

Scanner.TriggerType controls how you want to activate the barcode scanner on Zebra Android devices, usually you can set it up or Hard (scan is activated pressing the hardware trigger button) or Soft (scan is activated as soon as you call the Scanner.read() method).To have an application that can use the Hardware trigger and having an on screen button to activate the scanner you can leave set the triggerType to Scanner.TriggerType.HARD and implement a login in the click event handler for the soft scan button so that you set the TriggerType to Scanner.TriggerType.SOFT_ONCE and then you call the Scanner.read() method. You can eventually check if there's another read active.This is a sample implementation that you can test adding a button in the Barcode API sample included in the EMDK for Android (latest is v4.0):
private void softScan() {   if (scanner != null) {   try {   // Reset continuous flag   bContinuousMode = false;  if (scanner.isReadPending()) {   // Cancel the pending read.   scanner.cancelRead();   }   scanner.triggerType = TriggerType.SOFT_ONCE;   scanner.read();  new AsyncUiControlUpdate().execute(true);   } catch (ScannerException e) {   textViewStatus.setText("Status: " + e.getMessage());   }  }}So, usually you work with a TriggerType.HARD, but when you press the SCAN button you disable any pending read and you switch to TriggerType.SCAN_ONCE.
The implementation of the status listener needs to switch back the scanner to TriggerType.HARDand call the read() method.
All the data are received by the same Data Listener.

CONTACT
Can’t find what you’re looking for?