androiddatawedge

Disable scanner programmatically in DataWedge


Actually i use Output Intent from DataWedge to send decoded data to my application, so in the application there is recorded a BroadcastReceiver which get the decoded data

private BroadcastReceiver myBroadcastReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();

        if (Objects.equals(action, getResources().getString(R.string.activity_intent_filter_action))) {
            //  Received a barcode scan
            try {
                displayScanResult(intent);
            } catch (Exception e) {
                //  Catch if the UI does not exist when we receive the broadcast
            }
        }
    }
};

The question is is it possible in some way disable the scanner without using EMDK? I would be able to disable the scanne if the following condition is true:

 if(Alerts.dialogError != null && Alerts.dialogError.isShowing()){
            // Here i should block the scanner
        }

Solution

  • Yes, there are two ways, the easiest of which being:

    Intent dwIntent = new Intent();
    dwIntent.setAction("com.symbol.datawedge.api.ACTION");
    //  Enable
    dwIntent.putExtra("com.symbol.datawedge.api.SCANNER_INPUT_PLUGIN", "ENABLE_PLUGIN");
    //  or Disable
    dwIntent.putExtra("com.symbol.datawedge.api.SCANNER_INPUT_PLUGIN", "DISABLE_PLUGIN");
    sendBroadcast(dwIntent);
    

    For more context, I just wrote a developer article about this at https://developer.zebra.com/blog/quickly-suspend-scanning-your-app-datawedge