Reputation: 125
How can I detect that the telephone does not have hardware keyboard and only in that case to force showing the virtual one? And how can I hide it?
I tried putting the focus like this but it doesn't work:
View exampleView = (View)findViewById(R.id.exampleBox);
exampleView.requestFocus();
If I force like this the virtual keyboard, the keyboard will appear also when a hardware keyboard is available, which doesn't make sense.
InputMethodManager inputMgr = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMgr.toggleSoftInput(0, 0);
And last but not least, how can I show directly the numerical or phone keyboard? (Not the normal keyboard)
Any idea?
Thanks!
Upvotes: 5
Views: 1045
Reputation: 3282
I would say use the Configuration class hardKeyboardHidden to see if the hard keyboard is out and if not then open the soft keyboard
Upvotes: 1