Search code examples
androidusbbarcode-scanner

How to get data without editText from USB Barcode Scanner on Android?


I have USB Barcode Scanner, and I want to get result after scanning without EditText. I'm trying use onKeyUp/onKeyDown methods, but I get only few symbols. Now I'm trying use Invisible EditText, but it not work too


Solution

  • You should use TextWatcher. But you need an EditText, you can make it invisible in your layout. It will be easier than key up/down methods.

    Basically it listens for the incoming characters and you can implement the methods like afterTextChanged, onTextChanged, where you can get the whole string, or particular character, etc.. Read more about it here:

    https://developer.android.com/reference/android/text/TextWatcher.html