androidkeypressbarcode-scannerenterhandheld

android- How to prevent enter key/click coming from barcode scanner


Hello I have an application which I got entries by barcode scanner. I use Zebra TC56 as testing device.

I need to show a warning message to the user and that is why I have a custom dialog box. Dialog box is being showed when user gets an error. Picture of my dialog box can be seen here : enter image description here

Below red part is a button and when button is clicked , dialog box will be closed and user will turn the latest screen.

Everything works fine but there is somethin I dont want. When user scans a barcode(enters data) button is trigered and dialog box is closed.

I want dialog box to be closed only by clicking the button(TAMAM) from the screen. But when I scan anything, dialog box is closed.

Here is the code of the dialog box class :

public class ViewDialog {
public void showDialog(Activity activity, String msg){
    final Dialog dialog = new Dialog(activity);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCancelable(false);
    dialog.setContentView(R.layout.customdialog);

    TextView text = (TextView) dialog.findViewById(R.id.text_dialog);
    text.setText(msg);

    Button dialogButton = (Button) dialog.findViewById(R.id.btn_dialog);
    dialogButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    dialog.show();

}

}

I tried to get focus to somewhere except the button(TAMAM) but it didnt help. If someone knows how to dismiss enter key from the barcode scanner, I really need some help and will be appreciated. (I already set the device to send Enter key because I need in other screens)


Solution

  • Few ways to do this that I can think of.

    Firstly, I presume you are using DataWedge to automatically append the enter key to scanned data, you could dynamically switch to a profile which did not send the enter key but was identical in every other way using the SWITCH_PROFILE API: http://techdocs.zebra.com/datawedge/6-3/guide/api/switchtoprofile/. This is presuming that you still need to be able to scan when the dialog is visible, if you wish to disable scanning entirely you could use the SCANNER_INPUT_PLUGIN API: http://techdocs.zebra.com/datawedge/6-3/guide/api/scannerinputplugin/.

    Secondly, you could use the EMDK profile API to change the parameters of the KeyStroke output plugin (http://techdocs.zebra.com/emdk-for-android/6-3/mx/data-capture/keystroke/#keystrokeoutput) then apply that newly modified profile. I've never tried that myself but it should work - check out the following sample for the principles behind that: http://techdocs.zebra.com/emdk-for-android/6-3/samples/data-capture/

    Thirdly, you could use the Java SDK for the scanner which gives you more control over how the scanner behaves (http://techdocs.zebra.com/emdk-for-android/6-3/api/)