I'm using the Android emulator to test my first Android application. While there is a functioning hard keyboard at the right side of the emulator window, the soft keyboard shows up when editing in an EditText control.
I'm aware of the option to hide the soft keyboard by using an instance of InputMethodManager, however I'm wondering why the soft keyboard does appear at all (when the hard keyboard is available).
To me, as a user, the soft keyboard in this case is rather distracting, hence I'd like to get rid of it if useful. - This question is about the practical context (i.e., is there any use of the soft keyboard when there is a hard keyboard, do real-world devices behave similarly to the emulator) and about general strategies to address the issue.
Thanks. I'll be upvoting any helpful hints.
On my G1, when the hard keyboard was opened, the soft keyboard didn't appear. But I'm not sure whether a device which ALWAYS has a keyboard opened (like the Samsung Galaxy PRO if I'm not mistaken) does the same.
Since the emulator doesn't have a slide keyboard, I think that's the case for this behavior.
With a touch screen device + hard keyboard you have the flexibility to use both. On most devices with hard keyboards the keyboard has to be dragged out. It's much easier to just tap the screen. If you want to type a lot you would take the trouble to slide the keyboard out.
Android gives you the flexibility to program for all these behaviors.
Actually, the AVD emulator does have a slide-out keyboard.
The AVD option "Keyboard support" indicates whether the emulated device has any form of physical keyboard. The option "Keyboard lid support" indicates whether the device has a keyboard that can be opened or closed (slid out or what have you).
As far as actually "opening" and "closing" the keyboard on a device set up with these options,
you need to switch the orientation which is generally what you do with real-world slide-out-keyboard phones, e.g. the original Droid:
Original Droid with slide-out keyboard open
In the emulator, you control this orientation change with Ctrl+F11/Ctrl+F12 or 7/9 (on the number pad only, with NumLk off).
You can confirm the keyboard opening and closing states by checking the value getResources().getConfiguration().hardKeyboardHidden == config.HARDKEYBOARDHIDDEN_YES
As far as whether the soft keyboard appears or not, it appears to me that handling such things is up to you as the programmer. Here's an example you can try in AVD:
Set up an emulator with "Keyboard support" and "Keyboard lid support" both set to yes.
Launch the emulator, then open Android's built in Messaging app.
Click in one of the text boxes - the soft keyboard should show up.
Switch the orientation of the emulator with Ctrl+F12 - the soft keyboard should now disappear
Note there seems to be a problem with the emulator itself, that switching back to portrait mode doesn't cause apps to redraw themselves back to portrait layout. but they will switch back to closed keyboard mode, which yields some odd, sideways-y behavior.
For an example of code to catch the keyboard opening/closing events, check out: http://www.how-to-develop-android-apps.com/how-to-detect-screen-orientation-change-in-android/
After testing on real world devices; On the motorola milestone that has a sliding keyboard that if it's open the soft keyboard is not shown, but when it's closed the soft keyboard is shown. On the HTC Cha-Cha, that has a permanently shown keyboard, the phone always uses the hardware keyboard. Even when in landscape and the hard keyboard would be very difficult to use it doesn't show a soft keyboard (Even after installing a soft keyboard I was unable to select it for use under Keyboard & Language Settings).
For additional information about the phone you can use the following.They will return the keyboard type and whether or not it is a hard keyboard and shown. Note: Phones without a hard keyboard that I've tested report that hardKeyboardHidden=2; (Which indicates hidden=yes), but type reports as soft keyboard which makes sense.
Configuration config = getContext().getResources().getConfiguration();
int keyboardHidden=config.hardKeyboardHidden;
int keyboard=config.keyboard;
http://developer.android.com/reference/android/content/res/Configuration.html#HARDKEYBOARDHIDDEN_NO
Related
When creating an Android virtual keyboard, is it possible to have the keyboard stay open even if no text is selected?
If not, is it possible to occupy the area where the keyboard is when it's open, so that the layouts of the opened app don't change?
Reason being that I am working on a physical keyboard attachment, and I am considering making something similar to the Samsung S8 keyboard attachment (https://eskerahn.dk/?p=2284).
I could easily make something that works with the visible virtual keyboard, but as soon as the virtual keyboard closes, the app would use the full screen and then part of the app would be behind the keyboard.
If there is a solution, it should be compatible with Android 11 and 12 (so sadly no wm overscan).
I discovered a strange behaviour in Flutter. I have a Zebra PDA with Android, and so I have an hardware keyboard on the device. If I press an hardware key on the device keyboard, the on-screen keyboard shows up, and I don't think that is supposed to happen. After some investigation, I found out that this happen as soon as I show a widget with a TextField on it. After the first time the on-screen keyboard appears, every time I press an hardware key the on-screen keyboard appears. This is very frustrating, because if I use hardware keys of course I don't need the on-screen keyboard. I don't really understand if this is an expected behaviour and, if so, how can I avoid it.
This doesn't seem to be an issue with Flutter, but rather on the device that you're using. If the device displays the softkeyboard on hardware keyboard key presses, it's likely that you need to have the softkeyboard disabled on the device's Settings.
On stock Android Settings, it's under System > Languages & input > Physical keyboard. Then toggle 'Show virtual keyboard'
I've also tried setting TextField keyboardType to null to see if it can forcefully disable the softkeyboard, but doing so just shows the default softkeyboard.
TextField(
keyboardType: null
),
In my application there is a search segment -- just like on the twitter app. When the user clicks the magnifying glass the search segment starts (a fragment) and the keyboard is suppose to pop up so the user can type the query into the search bar.
What actually happens is the cursor is blinking in the search bar, and I can type into the bar with the hard keyboard, but the soft keyboard doesn't pop up. If I click the search bar, then the soft keyboard pops up.
Any ideas why the soft keyboard isn't popping up when the cursor is blinking in the search bar?
Apparently the soft keyboard isn't enabled by default on Genymotion.
I've turned on the soft keyboard by going to Settings | Language & Input | Current Keyboard and turning on the Show Input Method switch. But I have had some difficulty with this.
Different API versions have different UIs for this setting and it's never quite clear how to get the soft keys to show. Sometimes I've set the soft keys to show and they still don't show. Maybe you have to set them then restart Android on the device.
But that's where the setting is, and if your experience is anything like mine, you'll get it soft keys to show after you jank around with it for awhile.
You must enable it from the Genymotion application:
Open Genymotion app, it will display the list of your Genymotion devices
On the device you want to use the virtual keyboard click on the setting icon
Then check the option "Use virtual keyboard for text input"
You will then have a virtual keyboard poping up when you click on an edit text.
This will work whatever the Android version of your device is.
I am developing an Android application. What I find most annoying during testing is, that the emulator always pops up that on-screen telephone keyboard whenever I click into a text input field. Since I input my data with the keyboard anyway I find that most annoying. Can one switch that on-screen keyboard appearance off? Or can one change that so that it at least presents a mini-qwerty keyboard as my actual device does, not that old-fashioned T9 keyboard?
Michael
You can disable the virtual keyboard in Settings->Language.
If you change orientation of the emulator it won't popup (KEYPAD_7, Ctrl-F11).
If you use cursor keys instead of clicking the fields, probably won't popup either.
Whatever you do, keep in mind that in actual devices it usually pops up anyway.
I am using the AVD manager in eclipse. Is there a setting that I can use to stop the on screen keyboard appearing when an input field has focus?
I tried has hardware keyboard = true, but then the emulator doesn't seem to start at all :-S
mstoic's answer works, but with one problem: Google voice typing gets enabled with no way to get rid of it.
Not sure if this is available in emulators of all Android versions, but I found this in Settings -> System -> Languages & Input -> Physical keyboard (API 29 emulator). It worked for my use case.
The emulated device should have a physical keyboard, therefore negating the need for a soft keyboard.
I tried it out now and this configuration combination works for me:
hw.keyboard=yes
hw.touchScreen=no
The AVD has a physical keyboard, but no touchscreen, therefore only the physical keyboard can be used for text input, and the emulator does not show the soft keyboard.
Simply disable the Gboard app on your emulator.
To do that, go to Settings > Apps > Gboard, and then click the "DISABLE" button.
If Gboard is not visible, make sure you select the three dots in the top right corner and select the "Show system" option.
In some apps, you may see the Voice input box instead of the keyboard, you can disable that too by disabling the Google app in the same way you disabled Gboard.