Detect if phone's keyboard is slid out - android

I'd like to set focus to an EditText and automatically bring up the virtual keyboard in certain situations. However, if a phone's hardware keyboard is slid out, I wouldn't want to. Is there any way to detect whether or not a phone's hardware keyboard (if one exists) is slid out? Or is there some functionality of the EditText that will handle all this for me?

if (getResources().getConfiguration().hardKeyboardHidden==Configuration.HARDKEYBOARDHIDDEN_NO)
{
//do stuff
}
To dive deeper, triggering OnConfigurationChanged on keyboard slide is explained in Activity restart on rotation Android

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

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.

Is there an option to have both soft and hard keyboards active?

I am developing a IME keyboard which will have a automobile dial pad as the input handler in android. More clearly, the dial pad turns decide which alphabet to select.if the dial pad is pointed to "a" and then click the center button of the dial pad, it selects alphabet "a".
But my question is, is there a way i can have both hardware and software keyboards active consecutively?
My need is, My dial pad soft keyboard comes up and then i need to test it by right and left arrow of the hardware keyboard.
Thanks in advance
For future users- if you're implementing your own keyboard you can override boolean onEvaluateInputViewShown in InputMethodService. This function controls if the keyboard is shown, and the default implementation is to return false if a hardware keyboard exists. Change it to return true and it will work.
I don't know a way to do it from inside of an app.
for navigation part, i found the solution.
go to settings->input -> default-> disable the hardware physical keyboard.
then if any text edit is used, the soft keyboard comes up and then we can use the physical keyboard to navigate. (only navigation) .

How to detect loss of accessibility focus with on-screen navigation buttons?

I'm looking at the Support4Demos from the Android SDK and I'm not sure if this is working as intended. Specifically, I'm referring to accessibility focus when using the Widget > Explore by Touch Helper demo. If I tap on one of the blue regions to give it accessibility focus then tap on the on-screen home button focus will switch to the home button. But if I tap on the same blue region as before nothing happens (but if I tap on the other blue region focus transfers from the home button). I'm testing this on a Kindle with on-screen navigation buttons.
Am I correct in assuming that focus should transfer back to the blue region? If so, what is the proper way to handle this? Presumably there would be a way to know that the user tapped on something outside of the app and in response to this I could clear state in the ExploreByTouchHelper but I'm not sure how I would go about that.

PhoneGap + Android page doesn't refresh after soft keyboard closes

Most of the time (but not always), when I finish typing in a or and the soft keyboard hides, the view area is left raised with a black space on the bottom. Clicking, tilting or otherwise engaging the phone corrects the screen. However, user's first motion is usually pressing , but if you click submit it jumps down and you actually just click on the text area again. How do you stop this and get the screen to reset after the keyboard closes.
Take a look at you AndroidManifest.xml
http://developer.android.com/guide/topics/manifest/activity-element.html
I think you need to change android:configChanges.
I have the exact same problem what i did was handle hidekeyboard even in javascript and do something like window.scrollTo(0,0) or $("input[type=text],textarea").blur();
This will cause the the screen to get back to normal position
But there is just one problem when click from input field of type = text to a input field password it internally hide the keyboard which causes the hidekeyboard event to fire and scrolls the screen to top. This is the only side effect of this
Let me know if you find the solution for this

Categories

Resources