Search code examples
androidandroid-viewandroid-input-method

Show soft input keyboard


I'm trying to show the soft input keyboard for a view on the touch event. This line works:

inputManager.toggleSoftInputFromWindow(getWindowToken(),0,0);

But this line doesn't work:

inputManager.showSoftInput(this,0);

Why is it so? What if I want to connect the soft input to the view? Thanks.


Solution

  • I think you are testing on emulator. not on real device?

    It will not open the keyboard on AVD but it will open on real device, which does not have Hard key board.

    To test it on AVD you need to disable the keyboard.

    To disable keyboard use

    Click on AVD manager > open you targeted AVD > Edit > Hardware > New > Keyboard Support > OK > Make it "NO"