TC21 Xamarin Android 9+ Hidden Fields Can't Set Focus

// Expert user has replied.
B Brian Hanna 2 years 2 months ago
3 3 0

Hello, We have an app written in Xamarin that worked great for scanning using TC20 or MC3300 on Android 7, 8 using devices with physical keyboards. With Android 9, 10 & 11 when the scan trigger is pressed, we are not able to set focus to the hidden field on our screens to receive the scanned input. In Android to receive focus a field must have Area (size), IsEnabled=True, IsVisible=True, IsFocusable=True, IsFocusableInTouchMode=True. Everything looks great.. but when we try to requestFocus or SetFocus specifically to the hidden field, requestFocus() returns false. Note that in DataWedge we send characters as Key Events including the TAB key.

The other thing that happens is we have to turn off the soft keyboard completely because if you have that on it will inject random characters into the scanned string.

Its almost as if our app isn't getting focus, even though it is receiving keyevents.

Please register or login to post a reply

3 Replies

J James Swinton-Bland

Hi,

According to the docs requestFocus will return false if "it can't be focused due to other conditions (not focusable in touch mode (isFocusableInTouchMode()) while the device is in touch mode, not visible, not enabled, or has no size)"

So it seems the API will not work if the view is hidden - see more info here: https://developer.android.com/reference/android/view/View#requestFocus()

May I recommend you implement a broadcast receiver to receive the data from DataWedge via an intent, and use this to inject the data into your application? More info available here: https://techdocs.zebra.com/datawedge/6-7/guide/api/tutorials/

B Brian Hanna

We were able to figure this out. We have a HiddenScannerValue field on screens to receive the scanned input. In our Xamarin XAML it was placed inside a "stacklayer" view that was not visibile. Moving it outside the stacklater resolved the problem. This only occurred for us with Android version => 9 and Zebra TC21 (TouchOnly) device. It is likely this is just an Android 9+ issue and nothing to do with Zebra TC21. Thanks for all the responses.

J James Swinton-Bland

Hi Brian,

Thanks for coming back & updating the thread - much appreciated! Glad your problem has been resolved.

CONTACT
Can’t find what you’re looking for?