Skip to content

Device with Zebra laser scanner (FX3XX / FX810)

FX3XX and FX810 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;
    }
}

Usage in intent mode

Instead of having the barcode data being delivered to the Android component having the focus, an alternative way is to get the barcode data from an Android Intent sent by the laser scanner service to the foreground application.

This way of doing is very useful when your barcode contains binary data which cannot be converted to text.

In order to use the Intent mode, you have to configure the Input method of the laser scanner service to Intent. This can be done:

  • from Settings > Laser Scanner -> Input method
  • or by using the BarcodeManager.setInputMethod(BarcodeManager.INPUT_METHOD_INTENT) SDK method

Then you can register for the Intent to be delivered to your application:

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        BarcodeReceiver barcodeReceiver = new BarcodeReceiver();
        IntentFilter filter = new IntentFilter(BarcodeReceiver.BARCODE_SERVICE_ACTION_SCAN);
        registerReceiver(barcodeReceiver, filter);
    }
}

public class BarcodeReceiver extends BroadcastReceiver {

    public static final String BARCODE_SERVICE_ACTION_SCAN = "com.famoco.barcodeservice.SCAN";

    @Override
    public void onReceive(Context context, Intent intent) {

        String action = intent.getAction();
        if (BARCODE_SERVICE_ACTION_SCAN.equals(action)) {
            int symbology = intent.getIntExtra("extra_symbology", -1);
            int length = intent.getIntExtra("extra_length", -1);
            byte[] data = intent.getByteArrayExtra("extra_data");

            // handle barcode data...
        }
    }
}

A demo application showing this method can be downloaded below:

  • Intent demo app (v1.0, apk) download
  • Intent demo app (v1.0, source code) download

Famoco barcode SDK

The Famoco barcode SDK can be used to programmatically access the settings normally found in Settings > Laser Scanner, as well as to trigger a scan from an application instead of having to press the hardware button:

  • Famoco barcode SDK (v1.3.0, jar) download
  • Famoco barcode SDK javadoc (v1.3.0, zip) download