Is the Android "KeyEvent.ACTION_DOWN" triggered by Zebra RFD8500

B Benoit Heintz 3 years 7 months ago
2 0 0

I have to implement real quick the integration of the RFD8500 in our Android app.
In my activity I override the "dispatchKeyEvent" method and detect the "KeyEvent.ACTION_DOWN" to concatenate a string.
I then split the string with "\n" to find all the lines entered.
It works well with a Bluetooth keyboard but I wonder if the RFD8500 can be used this way. I don't know if the event "ACTION_DOWN" will be triggered or not.
Did anybody already try that?

private String keyboardInput = "";
@Override
public boolean dispatchKeyEvent(KeyEvent KEvent)
{
int keyaction = KEvent.getAction();
int keyunicode = KEvent.getUnicodeChar(KEvent.getMetaState());
char character = (char) keyunicode;
if(keyaction == KeyEvent.ACTION_DOWN) {
//Add character to string
keyboardInput += character;
//Split string in lines
String[] lines = keyboardInput.split("\n");
Integer line_length = lines.length + (keyboardInput.endsWith("\n") ? 1 : 0);
//For each lines, call the function "gotBarcode(String barcode)"
for (int i = 0; i line_length-1; i++) {
if (lines[i].trim().length() > 0) {
gotBarcode(lines[i].trim());
}
}
}
return false;
}

CONTACT
Can’t find what you’re looking for?