touchEvent while typing with soft keyboard android - android

in my application I would like to receive touchEvent(MotionEvent) event while the user is typing using his soft keyboard on a TextView. I have already tried using dispatchTouchEvent(MotionEvent) on the main activity, but during the typing this event is not fired. Is there a way to handle it?
EDIT:
The main idea is to have from the soft key two different events, one for the letter submitted (for example as with keyUp and keyDown) and one relative to the touch like dispatchTouchEvent, since when you press for a letter you touch the screen, meaning that you should arise a dispatchTouchEvent or something similar.

It's not possible to get touch events from the soft keyboard as Android keyboards are basically separate Android apps that already consume their touch events. However you can react on their key presses using the onKeyDown and onKeyUp events. See also http://developer.android.com/training/keyboard-input/commands.html

Related

.NET MAUI Entry keyboard does not hide

I have a very simple UI that has one entry control to enter phone number and a button. The entry control has a handler for removing border around it. When the entry control got focus, keyboard pops up. But when I try to tap outside the entry control such as on the screen empty area, the keyboard does not dismiss and the entry control does not lose focus. Also since the button is at the bottom of the screen, therefore, the soft keyboard hides it and there is no way to tap the button. The button can only be tapped if I press the Android device back button.
At present, I have not checked this behavior on an iOS device.
This was not a problem in Xamarin Forms though. I searched a lot on Internet and found that it is currently a bug in MAUI.
I tried to attach a tap gesture on the parent layout control and invoked platform-specific code to hide the keyboard but it seems the entry does not lose focus and in turn the tap gesture event is never called.
However, the entry control should lose focus automatically when I tap outside the entry control (such as on the screen) and the soft keyboard should automatically dismiss.
Please provide a workaround if there is any.
Known bug. Removing the focus sometimes helps. Sometimes you need to do Disable/Enable in sequence. (I go with the second).
If you want, you can read this for example:
https://github.com/dotnet/maui/issues/12002
(Most disturbing part, considering this is know bug for half year+)
We can leave the behavior how this is for now in NET7 and provide an
API in NET8 that lets users toggle this behavior on/off for iOS and
Android

Make onFocus event available on a touchable element in React Native on non-TVs

Is there any way to enable onFocus, onBlur etc. on Touchable-Elements on non-TVs devices?
The touchable elements event is not triggered, but the default feedback is visible when I use the physical keyboard.
I need simple dialogs on a Zebra mc3300. This device has a physical keyboard and when I show a dialog with a yes/no question, one button should have focus when the dialog becomes visible.
I'm not sure, maybe ref.current?.focus() works, when I press enter the key onPress is triggered, but i don't get any visible feedback which key has the focus. Only when I use the hardware button to switch to the next element and back again, the button became a different opacity.
Many thanks to you.

Disable Touch When Running ACTION_RECOGNIZE_SPEECH Intent

Part of my Android app uses speech-to-text, and I want to disable touch events while it does that because otherwise the user can accidentally touch their phone and stop the conversation.
I'm trying to use a ViewGroup that can be the parent for that Activity and absorb the touch events, but am having trouble with it.
I have an Activity, and from there I pull up a DialogFragment where the user can enter information using speech-to-text.
When I tried using an overlay to absorb the touch events from the dialog, it only covered the DialogFragment and not the whole screen. And when I added it to the Activity, I couldn't access it from the DialogFragment.
In any case, it never stopped the touch events anyways because my main problem is when the speech-to-text dialog is up and that would come up on top of the overlay and I don't know how to get the handle for that.
Anyone here done anything like this before? Thanks.

InputMethodManager showSoftInput method

What is the purpose of the method showSoftInput in class InputMethodManager? I am new to android, and well for me the documentation is not very clear :
Explicitly request that the current input method's soft input area be shown to the user, if needed. Call this if the user interacts with your view in such a way that they have expressed they would like to start performing input into it.
From what I have understood it opens the keyboard, am I am right? Why should we use this method, doesn't touching an EditText open automatically the keyboard??
No, touching an edit text doesn't automatically open a soft keyboard. That's just the default behavior. Under the hood, when you touch the edit text a series of events occurs. Eventually the Android framework will call showSoftInput on the IMS of the keyboard. This is the keyboard's chance to decide it doesn't want to show for some reason and return false if it is not shown. For example, I believe at Swype we overrode this not to show the keyboard if there was a hardware keyboard on the device already slid out, on the theory they then wanted to use the hardware keyboard.
Most of the time you're just going to either use the default implementation here, or do a few minor checks then fall back to the default implementation.

How to disable Android touch

There are some application that disables all the touch inputs, including the touch events that occur on the navigation bar.
Examples are Touch Lock or UnTouch. How one can do that?
By analyzing the second linked app seems that there is a hidden layout that capture the touch events (like an empty onClickListener).
Initially I tried to draw a transparent foreground using the SYSTEM_ALERT_WINDOW permission and by assigning an empty touch listener. However in this way I cannot draw on the navigation bar, so the user can touch the home button and the back button.
Another way that I tried is to launch an Activity with transparent background and in fullscreen mode. In this way I can capture all the events. This works, but obviously this causes other activities to go in pause state.
So my question is, how can one reach the goal? Alternatively is possible to use some root/system commands?
Thanks!
Try this link. If you want to do it on just 1 view then edit out the iteration in the methods given.

Categories

Resources