I want to differentiate keyboard input and barcode scanner input. I am able to capture barcode input when it is not focused on EditText.
override fun dispatchKeyEvent(event: KeyEvent?): Boolean {
if (event?.action == KeyEvent.ACTION_MULTIPLE) {
// Barcode Scanner event
}
return super.dispatchKeyEvent(event)
}
However, when the focus is on the EditText, it only dispatch KeyEvent.ACTION_UP and KeyEvent.ACTION_DOWN for pressing the scan button. The text is written to EditText directly.
I have tried to extend EditText and override dispatchKeyEvent on EditText instead of Activity but it still does not dispatch KeyEvent.ACTION_MULTIPLE.
Am I missing something? Where is the KeyEvent.ACTION_MULTIPLE being consumed?