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


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.

Submitted by James Swinton … on January 26, 2022 Permalink


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:

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:

Submitted by brianh@integra… on January 28, 2022 Permalink

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.