Get Scanner Status

DataWedge 11.0

GET_SCANNER_STATUS

Introduced in DataWedge 6.5.

Returns the status of the scanner currently selected by DataWedge as the default.

Function Prototype

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

Parameters

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

EXTRA_DATA [String]: "com.symbol.datawedge.api.GET_SCANNER_STATUS"

EXTRA VALUE: Empty string

Return Values

Returns a String of the name of the active DataWedge Profile

EXTRA NAME: "com.symbol.datawedge.api.RESULT_SCANNER_STATUS"

EXTRA TYPE [String]: [ ] Possible values:

  • WAITING - Scanner is ready to be triggered
  • SCANNING - Scanner is emitting a scanner beam
  • DISABLED - Scanner is disabled
  • CONNECTED - An external (Bluetooth or serial) scanner is connected
  • DISCONNECTED - The external scanner is disconnected

Example Code

Query Scanner Status

//Sending the intent to query scanner status
    Intent i = new Intent();
    i.setAction("com.symbol.datawedge.api.ACTION");
    i.putExtra("com.symbol.datawedge.api.GET_SCANNER_STATUS","");
    i.putExtra("SEND_RESULT","true");
    i.putExtra("com.symbol.datawedge.api.RESULT_CATEGORY","android.intent.category.DEFAULT");
    this.sendBroadcast(i);

Register to Receive Query Results

private void registerReceivers(){
    IntentFilter filter = new IntentFilter();
    filter.addAction("com.symbol.datawedge.api.RESULT_ACTION");
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    registerReceiver(receiver,filter);
}

Receive Query Results

// Receiving the results

ResultIntentReceiver receiver = new ResultIntentReceiver();

class ResultIntentReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
            if(intent.hasExtra("com.symbol.datawedge.api.RESULT_SCANNER_STATUS")) {
                String scannerStatus = intent.getStringExtra("com.symbol.datawedge.api.RESULT_SCANNER_STATUS");
                Log.d(TAG,"Scanner status:"+scannerStatus);
            }
    }
}

Unregister (to Release Resources)

private void unRegisterReceivers(){
    unregisterReceiver(receiver);
}

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