The myPOS Slim device has a barcode scanner that can be utilized without the integration of the Smart SDK. It is used by emulating a keyboard directly from the Android and it can be used in two ways:
- The first option is to capture the barcode using the EditText UI component.
- The second option is to use the standard function for key event handling. It can be seen from the example below:
String barcode = null;
@Override
public boolean dispatchKeyEvent(KeyEvent e) {
if (e.getAction() == KeyEvent.ACTION_DOWN) {
if (e.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
Log.i("LOG", "scanned code: " + barcode);
barcode = null;
return false;
}
else {
if (barcode == null)
barcode = "";
char pressedKey = (char) e.getUnicodeChar();
barcode += pressedKey;
}
}
return super.dispatchKeyEvent(e);
}