Report : New device with barcode scanner

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Report : New device with barcode scanner

Post by bangkok » Sat Sep 22, 2018 12:02 pm

I bought a Zebra TC20 (version without keyboard), with Android 7.

https://www.zebra.com/us/en/products/mo ... /tc20.html

LC 9.01 is running fine on it (no black screen issues).

This device has an integrated barcode scanner.

Works very well.

Like other Android devices with such scanner or USB models for PCs, the concept is always the same : the barcode scanner "emulates" the keyboard.

It's straightforward : you focus on a native field (or a LC fied), you push the button, the scanner reads the barcode and send the "keys" into the field.

The app coming with the TC20 allows to set a huge number of parameters for the scanner and the scanning operations (prefix, suffix, and even post processing, profiles etc.)

To give you an idea, here is the doc :
https://www.ptsmobile.com/zebra/tc20/tc ... -guide.pdf

All this for 400 euros (VAT included).

Now I have a question : I don't want to focus on a field. I'm looking for a way to "catch" the keys sent by the barcode scanner, on the fly.

On PC/Windows, it's easy I use (in the card script) :

Code: Select all

on keyDown theKey 
do something
end keyDown
The LC dictionary says that it's compatible with Android.

But it's not. It doesn't work.

Do you have any idea how I could "mimic" such behavior on Android ? And not using a native field or LC field ?

AndyP
Posts: 614
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Re: Report : New device with barcode scanner

Post by AndyP » Sat Sep 22, 2018 2:29 pm

Have a look at
rawKeyDown
in the dictionary see if that works better in your case.
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Report : New device with barcode scanner

Post by bangkok » Sun Sep 23, 2018 10:30 am

AndyP wrote:
Sat Sep 22, 2018 2:29 pm
Have a look at
rawKeyDown
in the dictionary see if that works better in your case.
Alas... no chance. Same results than with KeyDown.

The conendrum remains : the barcode scanner emulates the android keyboard... the android keyboard appears when the user focuses on a field (native or LC), therefore the barcode scanner sends the "keystrokes" into the field.

I still can't find a trick to "intercept" the keystrokes.

SparkOut
Posts: 2839
Joined: Sun Sep 23, 2007 4:58 pm

Re: Report : New device with barcode scanner

Post by SparkOut » Sun Sep 23, 2018 11:01 am

There is a thread that mentioned one trick but not a complete solution. Whether it still applies with current versions of Android and/or LC i don't know.

http://forums.livecode.com/viewtopic.php?f=53&t=28280

You might get another foothold out of it though

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Report : New device with barcode scanner

Post by bangkok » Sun Sep 23, 2018 11:41 am

SparkOut wrote:
Sun Sep 23, 2018 11:01 am
There is a thread that mentioned one trick but not a complete solution. Whether it still applies with current versions of Android and/or LC i don't know.
Yes I 'm facing the same issue since long time (Android 5.1) and other devices. I thought that with LC 9, Android 7 and a new device it would be solved.

I start to think that the only solution is to use the "Android intent" system.

This option is available through the settings of the Zebra TC20.

Someone could write such thing using Infinite Livecode ?

https://livecode.com/infinite-livecode-an-example/

Here is the doc about the intent parameters :

Intent Overview
The core components of an Android application (its activities, services, and broadcast receivers) are activated by
intents. An intent is a bundle of information (an Intent object) describing a desired action - including the data to be
acted upon, the category of component that should perform the action, and other pertinent instructions. Android
locates an appropriate component to respond to the intent, launches a new instance of the component if one is
needed, and passes it the Intent object.

Components advertise their capabilities, the kinds of intents they can respond to, through intent filters. Since the
system must learn which intents a component can handle before it launches the component, intent filters are
specified in the manifest as <intent-filter> elements. A component may have any number of filters, each one
describing a different capability. For example, if the manifest contains the following:

Code: Select all

<intent-filter . . . >
<action android:name=”android.intent.action.DEFAULT” />
<category android:name=”android.intent.category.MAIN” />
</intent-filter>
In the Intent output plug-in configuration, the Intent action would be:

Code: Select all

android.intent.category.DEFAULT
and the Intent category would be:
android.intent.category.MAIN.
The Intent delivery option allows the method by which the intent is delivered to be specified. The delivery
mechanisms are Send via startActivity, Send via startService or Broadcast intent.
The decode related data added to the Intent’s bundle can be retrieved using the Intent.getStringExtra() and
Intent.getSerializableExtra() calls, using the following String tags:

• String LABEL_TYPE_TAG = “com.symbol.emdk.datawedge.label_type”;
• String contains the label type of the bar code.
• String DATA_STRING_TAG = “com.symbol.emdk.datawedge.data_string”;
• String contains the output data as a String. In the case of concatenated bar codes, the decode data is
concatenated and sent out as a single string.
• String DECODE_DATA_TAG = “com.symbol.emdk.datawedge.decode_data”;
• Decode data is returned as a list of byte arrays. In most cases there will be one byte array per decode.

For bar code symbologies that support concatenation e.g. Codabar, Code128, MicroPDF, etc., the
decoded data is stored in multiple byte arrays (one byte array per bar code). Clients can get data in
each byte array by passing an index.

Most scanning applications might want the user to be able to decode data and for that decode data to be sent to
the *current* activity but not necessarily displayed. If this is the case, then the activity needs to be marked as
‘singleTop’ in its AndroidManifest.xml file. If your activity is not defined as singleTop, then on every decode, the
system will create another copy of your Activity and send the decode data to this second copy.
Last edited by bangkok on Sun Sep 23, 2018 12:09 pm, edited 1 time in total.

AndyP
Posts: 614
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Re: Report : New device with barcode scanner

Post by AndyP » Sun Sep 23, 2018 11:43 am

Does this work?

before keyUp theKey
answer theKey
end keyUp
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search

SparkOut
Posts: 2839
Joined: Sun Sep 23, 2007 4:58 pm

Re: Report : New device with barcode scanner

Post by SparkOut » Sun Sep 23, 2018 12:10 pm

:oops: I hadn't noticed that you were the OP in that thread too :roll:

Post Reply

Return to “Android Deployment”