Android Power Keyboard

My function, launched from onResume (), does not cause the keyboard to appear.

Am I doing it wrong?

private void showKeyboard() { InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mgr.showSoftInput(txtSearch, InputMethodManager.SHOW_FORCED); txtSearch.requestFocus();} 
+1
source share
2 answers

A soft keyboard can sometimes be tricky. I believe in the last line, txtSearch.requestFocus() not needed, and in fact something can be screwed. Speaking to the SHOW_FORCED keyboard on txtSearch, you already indicate that it has focus.

0
source

GetWindow () setSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE). can help you. Please note that there are Android devices with hardware keyboards. eg. GoogleTV devices often do not have a touch screen, but a hardware keyboard. Some of them even emulate a touch screen.

This is relevant if you are developing an emulator:

http://plainoldstan.blogspot.com/2010/09/android-set-focus-and-show-soft.html

"When I experimented, I didn’t get what I wanted, until I realized that I should have an emulator device without a hardware keyboard:"

0
source

Source: https://habr.com/ru/post/924313/


All Articles