External scanner and how to capture the data using an Edittext

alvinmb

Member
Licensed User
Longtime User
I have an external scanner that I want to use to scan a barcode. The device is setup as a keyboard wedge. Im using an Edit text field with focus to scan the text into. The input text is of variable length.

How do I know when all the text has been scanned into the edittext?
I have tried using TextChange event but that does not work or I don't know how to use it properly.

When I get the input text I then need to turn it around and send it to a server to be validated. That bit I do have working....:)
 

alvinmb

Member
Licensed User
Longtime User
The device does not send a suffix. The problem that I have is knowing when the input stream has finished. I tried using the Textchange event, however while the event triggers it only appears to send the OLD text, each time and it ignores break points when you debug, so they fire one after the other. - New text is always empty. I don't know if this is a bug or I just don't understand how it is supposed to work.
 
Upvote 0

boastrike

Member
Licensed User
Longtime User
I'm curious the type of scanner it is. Can you configure the scanner to add the carriage return? I havent found many scanners that you can't. If not is there an option to use a different scanner?
 
Upvote 0

alvinmb

Member
Licensed User
Longtime User
The scanner is a KDC 300, and yes you can add a termination character. I am going to try this today.
 
Last edited:
Upvote 0

Roger Garstang

Well-Known Member
Licensed User
Longtime User
Is the configuration by scanning barcodes with the scanner or configuration on the android side? We test all kinds of scanners at my work and if they don't have multiple options we don't use them. Often we need to send Tab after or various other chars.

If this still doesn't help (May not get CrLf in single line control) you could check for text length. Make sure all your barcodes are a fixed length and grab them when they are matching that. As far as the Textchanged event- it should be passing both the old text and the new text. Assuming you aren't doing some type of rapid fire scanning you should just need the new text. Grab what count of chars you need when they come and use them. Now since this is in wedge mode it is typing the chars like you do on the keyboard, so the event may fire for every char...you just have to wait for new text to be long enough. If you happen to scan another before it processes you may need to grab the first X chars and set the text of the control to what remains instead of clearing it after processing.
 
Upvote 0

Roger Garstang

Well-Known Member
Licensed User
Longtime User
Found what looks like a manual for it. Looks like some KTsync app can add a termination char as it comes in (Sounds like that is for packet mode though) or you can scan barcodes to have it as part of the data in barcode only mode. Available options are <NONE>, <CR>, <LF>, <CR+LF> or <TAB>. Might see if single line edit views give you Tab chars, otherwise you may need to use LF and a multiline box and check for line counts or something.

This also mentions a packet mode instead of Wedge. You may be able to link to a Serial connection and process data in another thread or something.
 
Upvote 0
Top