Java – Why doesn’t showSoftInput show the virtual keyboard?

Why doesn’t showSoftInput show the virtual keyboard?… here is a solution to the problem.

Why doesn’t showSoftInput show the virtual keyboard?

Essentially, I’m trying to display the virtual keyboard and collect input without using a visible EditText or TextView. I realized that toggleSoftInput could be used to do this, but I needed to use showSoftInput because I wanted to use TextWatcher to manipulate input. Also, the engine I use is C++, so I try to write as little pure java code as possible and thus avoid using .xml files. So here….

public class GameActivity extends Activity {

protected GameView view = null;
    protected EditText editText;

protected void onCreate(Bundle bundle)

view = new GameView(this);

editText = new EditText(this);

public boolean showKeyboard()
        JniApp.log("showKeyboard() in Java invoked!!!");


InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(editText, InputMethodManager.SHOW_FORCED);

showKeyboard() is my C++ call to Java. I’ve checked to make sure editText is receiving focus, and it is. However, showSoftInput returns false. Any help would be appreciated.

Update: After some debugging, it looks as if requestFocus returned true but the activity still says view is the current focus.


Maybe try using a . SHOW_IMPLICIT instead of . SHOW_FORCED ?

Have you tried it on other emulators/devices (and maybe other Android versions)?

Related Problems and Solutions