Android Question Barcode reader

EduardoElias

Well-Known Member
Licensed User
Longtime User
Hi There!

I am using a Barcode reader attached by USB to a Tablet

There is a strange thing happening, I am using the Barcode as a Keyboar simulation

Then I get the Keycodes by Activity_Keypress

It gets everything and my app recognizes and insert the item, however at very end of this process the app crash and in debug mode says nothing. Just close and a small dialog saying that the app closed.

There is one tablet Motorola Xoom where it works just fine, however in many others it cause the same problem. With different Android versions.

Is this the correct way to work with USB barcode readers?

thank you
 

imbault

Well-Known Member
Licensed User
Longtime User
Hi, the mini reader I used, worked perfectly (bluetooth) 1D and 2D

Log the captured charaters to see
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
I am loging it and are just fine... numbers and an enter at the end...

The problem is that after receiving all of this it crashes
 
Upvote 0

imbault

Well-Known Member
Licensed User
Longtime User
I will see tomorrow, my barecode readers are at this office, can you send me export of your project to try your code?

BTW, which brand is your reader? is it 1D, 2D? did you parametered it properly?
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
thank you for you help, however my code is giant... and depend on server to work.... it is just big...

I am using regular USB barcode reader (those chinese cheap ones used on PC for POS)

In a PC it works nicely

On tablet opening a notepad like app, it does type in the numbers and hit enter at the end

on my app it does type in all the numbers, but it cause the app to crash with no debug info
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
I am not using control, I am getting KeyCodes using the Activity_Keypress and then consuming the event.

I have my own interface, so I dont use any EditText or similar. It recognizes it just fine, all the digits comes correct, enter at the end algo works. However at some point after everything is done the program crashes. I went step by step and everything is just fine. Since I dont have any debug information I dont know anymore what to do
 
Upvote 0

PCastagnetti

Member
Licensed User
Longtime User
I solved the problem this way: Once you've created the data string from the barcode reader in your Activity_keypress, run your code using CallSubDelayed or a timer


In Activity_keypress:
B4X:
Dim mChar As String=ConvertCode(KeyCode)
            If mChar=crlf Then ' end of string from the scanner

                    CallSubDelayed2(Me,"RunTheCode",lastR) 'your code here
               
            Else
                lastR=lastR & mChar
            End If
Return True
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
It is not about any of this..... sorry I am not getting clear to explain.

I get alll the codes just fine. But using the USB Barcode Scanner cause to crash my application.

It is not the code itself. It reads fine, I get the code, the program find the item on the database and just fine... but the program crashes from nothing, just disappear. It only works fine in an old Motorola Xoom. New tablets like Samsung Tab E just crashes

It should not happen this, my question is about what could be happening to cause this problem. Is there a better way to read from the scanner instead using keyboard emulation?

Thanks for the try
 
Upvote 0
Top