How to make the virtual keyboard show and hide if the hardware keyboard is not available?

How can I detect that the phone does not have a hardware keyboard, and only in this case, to force the virtual display? And how can I hide it?

I tried to set focus in this way, but it does not work:

View exampleView = (View)findViewById(R.id.exampleBox);
exampleView.requestFocus(); 

If I use the virtual keyboard forcibly, the keyboard will appear if there is a hardware keyboard, which does not make sense.

InputMethodManager inputMgr = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMgr.toggleSoftInput(0, 0);

Last but not least, how can I show a numeric keypad or keyboard? (Not a regular keyboard)

Any idea?

Thank!

+5
source share
1 answer

, hardKeyboardHidden, , , ,

+1

All Articles