Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable physical keyboard in code(use virtual keyboard all the time)

You might ask why do I want that. Here is the reason:

I used a barcode scanner for the login screen of my application. However connecting the barcode scanner will force my tablet to use the physical keyboard (it thinks the scanner is the keyboard) and that prevents the virtual keyboard from coming up (which I want for some other screens). I have to manually click on the system bar to disable the physical keyboard for the virtual keyboard to popup.

So, is there a way to disable the physical keyboard in code or make the virtual keyboard come up even if some "keyboard" is connected?

like image 519
Han Avatar asked Nov 15 '11 22:11

Han


2 Answers

Try the following

Settings > Language & Input > Under Keyboard and input methods click Default. Is there an option to to uncheck or disable Hardware/Physical Keyboard?

It's counter intuitive, but after doing that, I can use both a physical keyboard and the virtual keyboard on my device (Android 4.2)

like image 149
Enrico Avatar answered Oct 08 '22 17:10

Enrico


This appears to have some revelance to your case. From the Configuration class documentation.

public int hardKeyboardHidden --- Added in API level 3

A flag indicating whether the hard keyboard has been hidden. This will be set on a device with a mechanism to hide the keyboard from the user, when that mechanism is closed. One of: HARDKEYBOARDHIDDEN_NO, HARDKEYBOARDHIDDEN_YES.

You can take some action on this config change. But I think there is no way to disable the physical keyboard in android.

Update

There the mHardKeyboardSwitch is a private member that holds a reference to the SwitchView which is used to reflect user's hardware keyboard preference. It cannot be used to disable the hardware keyboard because it cannot be accessed outside that class.

like image 3
Ronnie Avatar answered Oct 08 '22 18:10

Ronnie