Hide the soft keyboard of an entry? #16061
Replies: 3 comments 2 replies
-
HI. For "enterprise" type devices, with the integrated scanner, I always suggest not to use the keyboard emulation to read the barcodes. Usually the major vendors give the possibility to use broadcasts with intents to retrieve the barcode. What device are you using? |
Beta Was this translation helpful? Give feedback.
-
I added a video of my app: Noterfassung.mp4 |
Beta Was this translation helpful? Give feedback.
-
for almex you can define the broadcastreceiver they talk about broadcast... you can take a look to my post to understand how to use broadcastreceiver to read barcodes |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am working on an app for Android which lets the user scan barcodes.
These barcodes with their quantities are stored into a local db for later use.
The scanner is build into the device and uses the keyboard buffer.
I have modified the Android MainActivity to have an OnPageKeyDown-Event where I call an Entry.Focus();
Unfortunately, I am struggling for some days now being unable to hide the soft keyboard.
I tried several things and failed with everything:
Handled the Focus-Event and called:
Entry.IsEnabled = false; Entry.IsEnabled = true;
Problem: it does hide the keyboard, but the scanner is no longer able to enter the keystrokes into the entry anymore.
I created a class NoKeyboardEntry with its own EntryRenderer, setting the
this.Control.ShowSoftInputOnFocus = false;
and calling
InputMethodManager.HideSoftInputFromWindow on IsFocused PropertyChanging.
Problems: it only works 50% as there is no soft keyboard when touching the entry,
but still pops up when the page shows up and when I focus the entry programmatically.
Also, the Android physical back-button is no longer working correctly.
I added [Activity(... WindowSoftInputMode = Android.Views.SoftInput.StateAlwaysHidden, ...] to the Android MainActitivy.
Also I added Window.SetSoftInputMode(Android.Views.SoftInput.StateAlwaysHidden); on OnCreate.
No effect.
I tried to call this code on creating the page:
Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping(...
... handler.PlatformView.InputType = Android.Text.InputTypes.Null;
No effect.
I wanted to give the Xamarin.CommunityToolkit a try since there seem to be some keyboard hide helpers,
but I get a wall of compatibility errors when trying to install :-(
Currently, the soft keyboard constantly is popping up and down again every second when I scan barcodes.
This solution is very clumsy. Why is there no simple keyboard="none" possibility!?
I use the following code to hide the soft keyboard:
Platform.CurrentActivity.HideKeyboard(Platform.CurrentActivity.CurrentFocus);
which is called over and over again since you apparently cannot find out if the soft keyboard is visible or not.
Do you have any ideas or suggestions?
Thanks,
Mirko
Beta Was this translation helpful? Give feedback.
All reactions