Android: reading keyboard leftovers

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
simon.schvartzman
Posts: 652
Joined: Tue Jul 29, 2014 12:52 am

Android: reading keyboard leftovers

Post by simon.schvartzman » Thu Jan 07, 2021 9:17 pm

Hi all, I wonder if it would be possible to read Android's keyboard buffer in order to gain access to was entered by another App.

Just to make myself clear I may be facing the challenge to develop an Android App that would read a barcode scanner, according to the handheld vendor they use a keyboard wedge approach
What is a keyboard wedge?

A keyboard wedge is an application that can acquire data and send it directly in the keyboard buffer, just as if it was typed on a virtual keyboard.
Any thoughts?

Thanks
Simon
________________________________________
To ";" or not to ";" that is the question

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

Re: Android: reading keyboard leftovers

Post by bangkok » Fri Jan 08, 2021 8:20 am

simon.schvartzman wrote:
Thu Jan 07, 2021 9:17 pm
Hi all, I wonder if it would be possible to read Android's keyboard buffer in order to gain access to was entered by another App.

Just to make myself clear I may be facing the challenge to develop an Android App that would read a barcode scanner, according to the handheld vendor they use a keyboard wedge approach
Very simple :

-create an android native text field
-use a script inside like this :
on returnkey

put the text of me into tText

answer "Barcode decoded "&tText

end returnkey
You need to program your barcode scanner, so it adds a CR (carriage return) at the end of each scan.

After that, it's like you said : a keyboard

-you scan a barcode
-the scanner will send the "text" directly into your field
-the CR special character will fire an action (your script)

(of course the field has to be selected, AKA with insertion point inside it).

I use this scheme in several apps.

simon.schvartzman
Posts: 652
Joined: Tue Jul 29, 2014 12:52 am

Re: Android: reading keyboard leftovers

Post by simon.schvartzman » Fri Jan 08, 2021 2:40 pm

@bangkok, many thanks for you useful and straightforward contribution. This is going to be very valuable to me!

Regards
Simon
________________________________________
To ";" or not to ";" that is the question

simon.schvartzman
Posts: 652
Joined: Tue Jul 29, 2014 12:52 am

Re: Android: reading keyboard leftovers

Post by simon.schvartzman » Sat Mar 20, 2021 7:55 pm

@bangkok, your suggestion is working fine but now I have another chanllenge.

I'd like data to be inputed only by trigering the scanner but as it is know the keyboard is visible when the field has the focus. Do you know any way to hide the keybaord and still be able to receive data coming from the scanner which as you know is emulating a keyboard...

Many thanks for any suggestions.
Simon
________________________________________
To ";" or not to ";" that is the question

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

Re: Android: reading keyboard leftovers

Post by bangkok » Sun Mar 21, 2021 2:22 am

Hélas, no. I haven't found a way to bypass the logic :

-in order to catch the data sent by the barcode reader the field must have the focus
-and the focus displays the virtual keyboard. Always !

This could be solved in the future... We need a command to hide the virtual keyboard.

That could be a solution
-focus on the field
-keyboard is displayed
-hide immediately the keyboard (with message openfield for instance or keyboardActivated)

But the best solution would be to make "android" compatible the commands keyDown , rawKeyDown etc.

Code: Select all

on keyDown theKey 
  if theKey is not a number then beep
  else pass keyDown
end keyDown
This is what is use for desktop apps linked to a barcode scanner. No need to have a field with focus.

The characters "typed" by the barcode scanner are sent directly to the card, and intercepted with keyDown.

simon.schvartzman
Posts: 652
Joined: Tue Jul 29, 2014 12:52 am

Re: Android: reading keyboard leftovers

Post by simon.schvartzman » Sun Mar 21, 2021 3:42 am

Hi @bankok, I really appreciate your suggestions but I'm afraid l need more help
That could be a solution
-focus on the field
-keyboard is displayed
-hide immediately the keyboard (with message openfield for instance or keyboardActivated)
which command should I use to hide the keyboard?

Code: Select all

on keyDown theKey 
  if theKey is not a number then beep
  else pass keyDown
end keyDown
keyDown isn't fired on Android...
Simon
________________________________________
To ";" or not to ";" that is the question

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

Re: Android: reading keyboard leftovers

Post by bangkok » Mon Mar 22, 2021 3:02 am

This could be solved in the future... We need a command to hide the virtual keyboard.


It's a wish.
;-)

I know that keyDown doesn't work on Android.

But it might in the future.

Post Reply

Return to “Android Deployment”