Skip to content

PX320 Imager (Android 7)

The PX320 has a built-in BarcodeImager to scan 1D and 2D barcodes. The barcode reader can be use in keyboard emulation mode (accessible from the settings) or through an SDK to have fine-grained control on the reader.

Controlling the barcode scanner (applicable when you are not using the barcode reader in keyboard emulation mode)

The Barcode reader can be used programmatically with Android intents to enable scan mode, trigger scanning events, getting the results, and releasing the barcode reader. If using intents is not your cup of tea, we also released a wrapper to make your life easier. The intents mechanism and the corresponding wrapper are for PX320 devices equipped with firmware PX320,1_v1.2.0_20190916 or later.

Demo application

Intents specifications

Here is the full spec of the intents in case you are not using the wrapper:

Intents to be sent to the scanning service

Device Action Expected behavior / Comment
com.zebra.sdl.action.ENABLE Enable the scanner service 1 - Do nothing if already enabled
2 - Settings → Shortcut → "Laser scanner key" should be checked
3 - com.zebra.sdl.action.ENABLED should be broadcast
com.zebra.sdl.action.DISABLE Disable the scanner service 1 - Do nothing if already disabled
2 - Settings → Shortcut → "Laser scanner key" should be unchecked
3 - The scanner should be released
4 - com.zebra.sdl.action.RELEASED should be broadcast
5 - com.zebra.sdl.action.DISABLED should be broadcast
com.zebra.sdl.action.START Start the scan 1 - Trigger a scan
2 - If the scanner is previously closed, First time it scans, ~1s delay is expected; subsequent scans should not have that delay
3 - com.zebra.sdl.action.STARTED should be broadcast
com.zebra.sdl.action.STOP Stop an ongoing scan 1 - Stops an ongoing scan
2 - Do nothing is no scan is ongoing
com.zebra.sdl.action.RELEASE Release the scanner so that camera can be used again 1 - If the scanner has been opened, release it; If not, do nothing.
2 - com.zebra.sdl.action.RELEASED should be broadcast

Intents extras

Intent extras Value type Used with intent Summary Expeced behavior Supported since
com.zebra.sdl.extra.PARAMETERS Bundle com.zebra.sdl.action.START Used to set parameters of the barcode scanner when starting a scan.
  • Multiple key value pairs can be put in the bundle
  • The key is a String representation of the parameters as specified in the zebra developer guide
  • The value can be either an Integer or a String. Invalid values behavior is unspecified. always consult the zebra developer guide
PX320,1_v1.1.0_20190717

Intents broadcast from the service

Intent Triggered by Intent extras
com.zebra.sdl.action.ENABLED Scanner service is enabled from Settings → Shortcut → "Laser scanner key" or programmatically
com.zebra.sdl.action.DISABLED Scanner service is disabled
com.zebra.sdl.action.STARTED When the scan is triggered
com.zebra.sdl.action.RELEASED When the scanner is released
com.zebra.sdl.action.SCAN_COMPLETE When a scan is completed com.zebra.sdl.extra.CONTENT
contains the content of barcode.

Sample code

Here some code extracts to do basic actions with the barcode reader. Please refer to the demo app for a more exhautive list of actions.

Send Intent to open the scanner

Intent intent = new Intent("com.zebra.sdl.action.START");
intent.setPackage("com.zebra.sdl");
intent.setFlags(Intent.FLAG_FROM_BACKGROUND);

// Optionally, set parameters, only supported since PX320,1_v1.1.0_2019xxxx
// in this case, set length of interleaved 2 of 5 barcode to [1,55]
Bundle bundle = new Bundle();
bundle.putInt("22", 1);
bundle.putInt("23", 55);
intent.putExtra("com.zebra.sdl.extra.PARAMETERS", bundle);

startService(intent);

Send intent to release the scanner

Intent intent = new Intent("com.zebra.sdl.action.RELEASE");
intent.setPackage("com.zebra.sdl");
intent.setFlags(Intent.FLAG_FROM_BACKGROUND);
startService(intent);

Receive broadcast intent from the service

broadcastReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        // do stuff
    }
};
registerReceiver(broadcastReceiver, new IntentFilter("com.zebra.sdl.action.RELEASED"));

Usage in keyboard emulation mode

  • To activate the laser, you can use the soft button into the app or the "Push To Talk" physical button on the left side of the device.
  • The result of the scan is displayed directly on the screen where your app has the focus (ex: Android TextField)
  • The beam turns off after a code is read or after 10 seconds.