Reputation: 4355
I have a USB QR code reader which works as any keyboard, throwing the read information text in any text input widget, as EditText
.
But, without using any widget, I would like to catch the read information text direct in a String
variable.
I'm almost sure this can be reached through streams: InputStream
or OutputStream
, but I don't know how to point to my external input device. Something like:
OutputStream outputStream = who.getOutputStream();
Someone has a clue?
EDIT 1
The QR reader device is a Motorola DS9208, which I'm using in conjunction with a Nexus 7. The QR reader is connected in the Nexus MicroUSB port via OTG cable and it starts to work automatically. It is possible to see what the reader has read with any app with a place to write text. The reader is recognized as a common keyboard.
Upvotes: 1
Views: 863
Reputation: 4355
Finally, I could catch the read information text direct in a String
variable.
Due that the QR reader works just like a hard keyboard (once it reads a QR code, it writes text), I could use an activity's built-in method called onKeyDown
.
This method is able to catch the letters written when a user presses the keys of a hard keyboard. So, since the QR reader works as a hard keyboard, the method can catch its letters in a String
variable.
I hope this helps someone.
Upvotes: 1