Can I programmatically disable/enable the physical keyboard? - android

I want to enable the soft keyboard when a scanner is plugged into the device. In order to do this I need to disable the hardware keyboard
Is there a way to disable/enable the use of hardware keyboard in Android 3.0+ programmatically?

Related

how to detect device keyboard events in flutter

How can i detect keyboard events in flutter? Specifically, I want to detect if user changes language in device keyboard.I DON'T MEAN DEVICE LOCALIZATION. I mean the language inside keyboard. Thanks

How to open Android Keyboard in Speaking mode programmatically?

I want to open the Android Keyboard in Speaking mode by default programmatically when I focus on editText.
I know android:inputType="voice" is in enhancement, is there
another way?
I don't want to use SpeechRecognizer because the difference with the one used by default in Android keyboard is that it works offline.

Using both soft keyboard and physical keyboard in Android app

is there a way to force soft keyboard in Android 4.4 app?
I'm developing an app which needs both software keyboard and bluetooth barcode reader. Barcode reader will be used in 99% of cases, but there are some options which require soft keyboard (e.g. typing e-mail address or password).
When barcode reader is paired with the phone, soft keyboard doesn't appear. I'd like to keep it that way, but when user enters a selected view soft keyboard should appear.
Thanks in advance!

Circumvent disabling android keyboard when a physical keyboard is plugged in

Using a card reader for a POS system that will be hooked into an android device. It seems to disable the android software keyboard while it is plugged in.
Is there a way to define whether or not to disable/enable the android keyboard per control or a way to circumvent the android soft keyboard being disabled?
Thanks,
W
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
.showSoftInput(editText, 0);
the above forces the soft keyboard to be visible. good luck

Why does the Soft Keyboard appear?

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

Categories

Resources