My DataWedge Keystroke output app works on TC51 but not TC20

I've been working on an app primarily being tested on TC51 devices. I use a DataWedge profile set up with barcode scanning and keystroke output (no intent output) and it works brilliantly on my TC51.

 

In MainActivity.java, I override dispatchKeyEvent(KeyEvent event) and get the character entered and keycode from there, and process it according to my app's needs. I can provide source code if needed.

 

This works great on my TC51 but now that I've installed my app on a TC20, it's not doing anything at all. I've tried logging what keys get pressed (in my dispatchKeyEvent, i check if it's ACTION_UP and then I log the keycode in my app) but that just produces a list of "285" keycode presses, which doesn't match anything in KeyEvent.Java

 

How can I get my app working with Keystroke output on the TC20?

Anonymous (not verified)
Hi,I suspect this is not

Hi,

I suspect this is not device specific but rather Android version specific, i.e. something that changed between M and N.  I did a similar test with a TC51 N device and dispatchKeyEvent did not fire.

DataWedge is not sending KeyEvents for each of the individual characters in the barcode but is only designed to work with text fields which is why this behaviour was never tested.

I spoke with the team & they are keen to understand the issue better (even if it is just better documenting exactly how the behaviour is supposed to work),

  • If you could please provide your source code it would help understanding the specific issue
  • If you could please let us know why the Intent mechanism was not acceptable for your application?  Typically I would expect applications that required DataWedge input without text fields to use Intents.

Thanks,

Darryn.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Sam Ross
Thank you DarrynI've used

Thank you Darryn

I've used Keyboard output thus far mostly because it was just easier. I was really struggling to get intents working, as the guides seem a bit over-complicated for an app that *merely needs to scan barcodes*. I found them hard to follow and when I tried following them to the letter, I ended up with an app that just wasn't receiving the data.

Whereas accepting keyboard output by overriding dispatchKeyEvent was very simple.

I'd prefer using an intent to be honest but it's just been a very frustrating experience.

It's a webview app. The source code links:

MainActivity.java

activity_main.xml

javascript for accepting text input from MainActivity.java

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
If you are using an embedded

If you are using an embedded WebView you might also consider our Enterprise Browser product as that exposes a Barcode API through JavaScript in an embedded WebView but I presume such a drastic change would be unacceptable at this stage in your development.

It does sound like Intents are the best way forward in your case.  I have a basic sample on my github to receive a scan via an intent (GitHub - darryncampbell/DataWedge-Intent-Example-1 ) if that helps.  I'll probably write a blog around it at some point as it's a question we frequently get.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Sam Ross
I followed your example code

I followed your example code and got intents working. Now able to send the barcode intents into my webview. It's actually exceedingly simple to get accepting intents working, I don't understand why the guides are so complicated.

Thank you!

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Edward Correia
Hi Sam-My name is Eddie

Hi Sam-

My name is Eddie Correia, and I'm responsible for the DataWedge docs on Techdocs. I'm glad you were able to get DataWedge working the way you wanted, and I'm sorry that our docs seemed complicated and/or weren't helpful.

If I might, I'd like to request that you provide some specific feedback on where and how we might improve or simplify the docs. Our goal is to make DataWedge guides easier for developers to use, and direct input from developers is an invaluable part of that.

Thanks and regards,

Eddie Correia

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Sam Ross
Sure.Every time I tried to

Sure.

Every time I tried to search for an example, I ended up on this one or one very similar. This exmaple included a 'softscan triggering' tutorial which is (if I understand what it is) unnecessary for my basic needs, and when I tried following the 'onNewIntent' code, I always ended up unable to get the data in my app.

Darryn's code was simple enough that I didn't even need a guide to understand how to apply it to my own app (although it might have been faster if it did have a guide). He makes a private BroadcastReceiver, registers it, and then... that's it. I have to make sure that the intent output string in DataWedge matches the string in the code, and then I'm good to go. I then can pass the information into my webview however I please, using the myWebView.evaluateJavascript() interface.

I came into the docs thinking what I wanted was literally the most basic possible thing you could do with a datawedge, but I couldn't find anything that simple in the tutorials or docs anywhere.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Edward Correia
Thanks Sam. We will add a

Thanks Sam. We will add a simpler tutorial. Feel free to send additional suggestions. -EC

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


Sam Ross
Will you update me when you

Will you update me when you've made that guide?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Edward Correia
Sure thing Sam. Here it is:
Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments