Skip to content

Device with Zebra laser scanner (FX3XX)

FX3XX devices have a built-in Zebra laser scanners (SE4710 for example) to scan 1D and 2D barcodes. This reader can be used with keyboard emulation mode and is configurable from Settings > Laser > Laser Scanner Service.

This way is recommended because it works out-of-the-box, without any code to add in your app. This is possible because Famoco implemented a ready-to-use solution with a system service in FamocoOS.

Usage in keyboard emulation mode

To activate the laser, you can use the physical button on the left side.

The result of the scan is displayed directly on the screen where your app has the focus (ex: Android TextField) or by catching the OnKeyUp event (cf. sample code).

The beam turns off after a code is read or after 10 seconds.

Demo application using an EditText

Alternative without EditText

public class MainActivity extends AppCompatActivity {
    private StringBuilder mBarcode;
    private TextView mTextViewBarcode;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mTextViewBarcode = findViewById(R.id.tvBarcode);
        mBarcode = new StringBuilder();
    }

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (keyCode != KeyEvent.KEYCODE_SHIFT_LEFT
                && keyCode != KeyEvent.KEYCODE_F1
                        && keyCode != KeyEvent.KEYCODE_F2) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                Log.d(TAG, "decoded text = " + mBarcode);
                mTextViewBarcode.setText(mBarcode);
                mBarcode = new StringBuilder();
            } else {
                mBarcode.append((char) event.getUnicodeChar());
            }
        }
        return true;
    }
}