Wednesday, July 6, 2011

Show Soft Keyboard for Text Entry

This snippet can be used to force the display of the soft keyboard

InpuptMethodManager im = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
im.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

However it is better to check first if the device has a hardkeyboard, in that case you might not want to show the soft keyboard.

boolean hasHardKeyboard = false;
Configuration config = getResources().getConfiguration();
if (config.keyboard != Configuration.KEYBOARD_NOKEYS) {
hasHardKeyboard = true;

No comments:

Post a Comment