Android Question Know if an EditText was typed or acquired by a barcode reader

vecino

Well-Known Member
Licensed User
Longtime User
Hello, an EditText where the user types in item codes.
The EditText itself can contain codes read with a barcode reader.

Is there any way to know if the code was typed by the user or read by the barcode reader?

Thank you.
 

vecino

Well-Known Member
Licensed User
Longtime User
Finally, there are many different options.
I will try them all before deciding on one.
Thank you very much, friends.
 
Upvote 0

Intelemarketing

Active Member
Licensed User
Longtime User
Thank you for your help.
The reason for my question is because the user has 2 different tables, one with the "normal" codes and another table with the barcodes.
So I wanted to know to search in one table or the other.
I will probably have to search in one, and if it doesn't exist, search in the other.
"I will probably have to search in one, and if it doesn't exist, search in the other."

This is the logical approach I personally would recommend, as in some cases, I am sure the operator will need to manually key a barcode.
eg, Label is damaged and the barcode won't scan and the PLU code cant be seen either.

International Barcodes are normally 8 or 13 digits in length. If the PLU Code Length is other than 8 or 13 digits, then that will tell you which
Field to scan first. Then you can always try the other.

Machines are are so quick these days, that doing a double scan will not be noticable, I should think.

Also as suggested by mc73, if you know which algorythim is used in the barcode, you can always try do a quick calc, to identify that the code is a PLU Keyed, or a Barcode. Typically a Barcode has "weightings" on each digit used to calculate the last digit - deemed the CDV "Check Digit Verifification Code".
eg, 1234567X where X is the CDV "may" be calculated using wighting of 121212etc
1 x 1 + 2 x 2 + 3 x 1 + 4 x 2 + 5 x 1 + 6 x 2 + 7 x 1 = 38
If the Base is 11, then the CDV will be 38 / 11 = 3 with a remainder of 5. In this example the CDV = 5 Barcode = 12345675

That is just an example - there are many different methods of calculating CDV depending on which was used.

 
Upvote 1

vecino

Well-Known Member
Licensed User
Longtime User
That is just an example - there are many different methods of calculating CDV depending on which was used.
Thank you very much for your advice.
The problem is that this application is used by different companies that use different types of barcodes, some don't use barcodes at all, some use them on some items, some have created their own personal barcodes...
Anyway, it's very variable and I can't use one particular method, which is why I have simply decided to find out if they are typing or reading with a barcode reader.
Thank you very much again.
 
Upvote 0

vic53

New Member
You can program some barcode to return a special char after the text read for example the return-code but if you program another char after the text that you retrieve from the scanning for example one funcional taste F2, F3... and work in for if this char is present or no, substitute the functional taste with return CHR(13) but before you can execute a function to execute another work...
 
Upvote 1

vecino

Well-Known Member
Licensed User
Longtime User
It can also be a good idea because the barcode reader adds a chr(13) at the end. However, when the user types then there is no such chr(13).
Thank you very much.
 
Upvote 0

Dave G

Active Member
Licensed User
If you use SPP then you can know if the barcode came from the scanner via SPP or was typed into a text field. The issue with HID is that the scan will go into the currently focused field on the form which may or may not be the correct field. With SPP the barcode scan comes into your app via Bluetooth events. Some scanners include what symbology was used so you can make sure they scanned the correct barcode. In addition, HID is very slow compared to SPP. IMHO.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Thank you very much for your advice.
The thing is that I don't decide which barcode scanner the customer will use. Each customer buys the one they want, so I can't control that aspect. Or rather, I don't know how to control that.
Thanks again.
 
Upvote 0

Dave G

Active Member
Licensed User
Thank you very much for your advice.
The thing is that I don't decide which barcode scanner the customer will use. Each customer buys the one they want, so I can't control that aspect. Or rather, I don't know how to control that.
Thanks again.
You're very welcome. I've been fortunate that the hardware used on my project through the years (30+) all had built-in scanners (Telxon, Symbol, HHP, Motorola, Zebra) that I had full control over e.g. could control which symbologies were allowed. BTW, Scan Avenger has a scanner that supports SPP and will prepend the scan with the symbology that was used, most others use HID and are difficult to control.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Thank you very much for your explanation. My knowledge on this subject is very limited, but I already have the email of someone who knows!!!! :D
Thanks again.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
We use barcode readers frequently and generally if they are scanning OUR codes we prepend a code so we know what to do with it. There are also devices that simply emulate the keyboard. They come with a "Driver" that is installed which does the emulation. A good example of these is is measuring devices such as calipers and micrometers. I a not sure how you would identify these. If there is a way to identify this I would be interested in knowing how to do it.

One thought that comes to mind. Measure the time between changes in the text changed event. I would imagine it would be substantially faster from a scan. While not perfect it would give you an idea of which table to start your search with.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Thank you very much for your information, it is very interesting, I will test what you have explained.
Best regards.
 
Upvote 0

Intelemarketing

Active Member
Licensed User
Longtime User
This suggestion is slightly outside my area of experience, but may be the definitive solution you are looking for.
It may also be useful for taking input other devices such as Weighing Machines and Credit Card Readers in a Point of Sale environment.


 
Upvote 1

aeric

Expert
Licensed User
Longtime User
I am also building a POS system and my simple solution is to let the user press a button to set the mode manually. I never thought it can be done automatically because I put the code for search barcode inside TextChanged. For example my SearchBarcode() sub only fired if blnScanMode = True or pressing Enter button. When blnScanMode = False, TextChanged will not fire the SearchBarcode() sub. I don’t need to know/log the source of the input.

 
Upvote 1

vecino

Well-Known Member
Licensed User
Longtime User
Thank you very much, friends.
I can't complain, the number of alternatives is impressive.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
At the moment I have to test them all, but of the ones I have tried, I think I will use the option to check if the length of "New" is greater than "Old" and the difference is greater than 2 characters, for example. Because a user can't type 2 characters at the same time, and copy/paste is not used by any user.
Thank you.
 
Upvote 0

Intelemarketing

Active Member
Licensed User
Longtime User
At the moment I have to test them all, but of the ones I have tried, I think I will use the option to check if the length of "New" is greater than "Old" and the difference is greater than 2 characters, for example. Because a user can't type 2 characters at the same time, and copy/paste is not used by any user.
Thank yoU
I am making the assumption that you are running your software on a PC - Not a phone. Why is it important to know if the data was keyed or scanned ? I can't imagine that the time difference of scanning one or two codes will even be noticable. Once a database is scanned, my experience is that the data gets buffered in Ram so that subsequent scans are often significantly quicker than previous scans. If you are doing a lookup across the Internet, on a very slow server, then perhaps what you are trying to achieve may be worthwhile - Local search/scan - insignificant time difference I would say. What I have said applies to current computer technology - up to 5 years old - On the other hand if you are running on a very old computer then every millisecond may be precious.

We normally have a prompt "Key Code" and a Text Field where you enter the Code of the Item and then press enter.
If there is a Barcode Scanner attached, we pre-program the Barcode Scanner to ADD the Hex 0D character (Enter Key) after the barcode was scanned.
(The Supplier/Maker of the Barcode Scanner can help with this).

Scan First Code - Valid ?
Scan Second Code if First Code Not Found

If you have a higher occurence of scanning vs keying codes then the First Code you try is the Barcode
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Hi, I'm going to try to explain it better, sorry for my deplorable English, I have to use the translator most of the time.
The application only works on android devices, users can type those codes, or they can read it with a barcode reader.
If the user types it, then in the "TextChanged" event the difference in length of "New" and "Old" will increase by one at a time.
If the user uses the barcode reader, the length will vary from zero to the total length of the code read.
I think that way I can always know the origin of the typed code: the user or the scanner.
I hope the translator didn't write any strange things.
Thank you very much.
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
If the user types it, then in the "TextChanged" event the difference in length of "New" and "Old" will increase by one at a time.
If the user uses the barcode reader, the length will vary from zero to the total length of the code read.

It would be a problem if the user copy and paste a barcode? Or it doesn't matter?
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
It would be a problem if the user copy and paste a barcode? Or it doesn't matter?
It can be a problem, but in this case it is not.
The user is not going to copy the barcode by hand into a notepad (for example) and then paste it into the application.
He would type it into the application, directly.
Anyway, I still have to do some tests and send them to some trusted customers who act as testers.
Best regards.
 
Upvote 0
Top