Enumerate Scanners

DataWedge 13.0

ENUMERATE_SCANNERS

Introduced in DataWedge 6.3.

Generates a numbered list (index) of scanners available on the device.

IMPORTANT: The scanner index is not fixed for all devices. It varies depending on the number of supported internal and/or external scanners installed and/or connected to the device at the time the index is generated.

Function Prototype

Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("com.symbol.datawedge.api.ENUMERATE_SCANNERS", "");

Parameters

ACTION [String]: "com.symbol.datawedge.api.ENUMERATE_SCANNERS"

Return Values

The enumerated list of scanners is returned via the broadcast intent com.symbol.datawedge.api.ACTION_ENUMERATEDSCANNERLIST. The list of scanners is returned as a string array (see below).

Bundle Extras

SCANNER_NAME [String]:

SCANNER_INDEX [String]:

SCANNER_CONNECTION_STATE [String]:

SCANNER_IDENTIFIER [String]: in each scanner info bundle for each scanner supported in the device (introduced in DataWedge 6.5). Both parameters are supported in DataWedge 6.6 and higher; the scanner identifier value takes precedence if an index also is referenced in the code.

Possible values:

  • AUTO - Automatic scanner selection
  • INTERNAL_IMAGER - Built-in imager scanner
  • INTERNAL_LASER - Built-in laser scanner
  • INTERNAL_CAMERA - Built-in camera scanner
  • SERIAL_SSI - Pluggable Z-back scanner for ET50/ET55
  • BLUETOOTH_SSI - RS507 Bluetooth scanner
  • BLUETOOTH_RS5100 - RS5100 Bluetooth scanner
  • BLUETOOTH_RS6000 - RS6000 Bluetooth scanner
  • BLUETOOTH_DS2278 - DS2278 Bluetooth scanner – does not apply to select devices, see Scanner Selection
  • BLUETOOTH_DS3678 - DS3678 Bluetooth scanner – does not apply to select devices, see Scanner Selection
  • BLUETOOTH_DS8178 – DS8178 Bluetooth scanner – does not apply to select devices, see Scanner Selection
  • BLUETOOTH_LI3678 – LI3678 Bluetooth scanner – does not apply to select devices, see Scanner Selection
  • BLUETOOTH_ZEBRA - generic term for Zebra Bluetooth handheld scanner (such as DS3678, LI3678, DS8178)
  • PLUGABLE_SSI - Serial SSI scanner RS429 (for use with WT6000)
  • PLUGABLE_SSI_RS5000 - Serial SSI scanner RS5000 (for use with WT6000)
  • USB_SSI_DS3608 - DS3608 pluggable USB scanner
  • USB_TGCS_MP7000 – MP7000 grocery scanner scale
  • USB_ZEBRA - Generic Zebra USB scanner

Example Code

Enumerate scanners

//
//  Call before sending the enumeration query
//
public void registerReciever(){
    IntentFilter filter = new IntentFilter();
    filter.addAction("com.symbol.datawedge.api.RESULT_ACTION");//RESULT_ACTION
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    registerReceiver(enumeratingBroadcastReceiver, filter);
}
//
// Send the enumeration command to DataWedge
//
public void enumerateScanners(){
    Intent i = new Intent();
    i.setAction("com.symbol.datawedge.api.ACTION");
    i.putExtra("com.symbol.datawedge.api.ENUMERATE_SCANNERS", "");
    this.sendBroadcast(i);
}

public void unRegisterReciever(){
    unregisterReceiver(enumeratingBroadcastReceiver);
}

//
// Create broadcast receiver to receive the enumeration result
//
private BroadcastReceiver enumeratingBroadcastReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        Log.d(TAG, "Action: " + action);
        if(action.equals("com.symbol.datawedge.api.RESULT_ACTION")){
            //
            // enumerate scanners
            //
            if(intent.hasExtra("com.symbol.datawedge.api.RESULT_ENUMERATE_SCANNERS")) {
            ArrayList<Bundle> scannerList = (ArrayList<Bundle>) intent.getSerializableExtra("com.symbol.datawedge.api.RESULT_ENUMERATE_SCANNERS");
            if((scannerList != null) && (scannerList.size() > 0)) {
                for (Bundle bunb : scannerList){
                    String[] entry = new String[4];
                    entry[0] = bunb.getString("SCANNER_NAME");
                    entry[1] = bunb.getBoolean("SCANNER_CONNECTION_STATE")+"";
                    entry[2] = bunb.getInt("SCANNER_INDEX")+"";

                    entry[3] = bunb.getString("SCANNER_IDENTIFIER");

                    Log.d(TAG, "Scanner:" + entry[0]  + " Connection:" + entry[1] + " Index:" + entry[2] + " ID:" + entry[3]);
                    }
                }
            }
        }
    }
};

Get scanner details

// RESULT_ACTION_EXTRA_ENUMERATE_SCANNERS

if(intent.hasExtra("com.symbol.datawedge.api.RESULT_ENUMERATE_SCANNERS")) {
    Log.d(TAG, ">>> RESULT_ACTION_EXTRA_ENUMERATE_SCANNERS <<<");
    ArrayList<Bundle> scannerList = (ArrayList<Bundle>) intent.getSerializableExtra("com.symbol.datawedge.api.RESULT_ENUMERATE_SCANNERS");
    if((scannerList != null) && (scannerList.size() > 0)) {
        for ( Bundle bunb: scannerList) {

            String ScannerName = bunb.getString("SCANNER_NAME");
            int ScannerIndex = bunb.getInt("SCANNER_INDEX"));
            Boolean ScannerConnectionState = bunb.getBoolean("SCANNER_CONNECTION_STATE");
            String ScannerId = bunb.getString("SCANNER_IDENTIFIER");

        }
    }
}

Comments

The scanner and its parameters are set based on the currently active Profile.


SEE ALSO:

Zebra Support Central | Integrator Guides, Product Manuals, Software Downloads and Support

LaunchPad | Zebra Developer Community

Intent | Android Developers

Intents and Intent Filters | Android Developers

Android Intents | Tutorial