Android show softkeyboard with showSoftInput is not working? Android show softkeyboard with showSoftInput is not working? android android

Android show softkeyboard with showSoftInput is not working?


When the activity launches It seems that the keyboard is initially displayed but hidden by something else, because the following works (but is actually a dirty work-around):

First Method

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);editText.postDelayed(new Runnable(){    @Override    public void run()    {        editText.requestFocus();        imm.showSoftInput(editText, 0);    }}, 100);

Second method

in onCreate to launch it on activity create

new Handler().postDelayed(new Runnable() {    @Override    public void run()     {    //  InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);    //    inputMethodManager.toggleSoftInputFromWindow(EnterYourViewHere.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);        if (inputMethodManager != null)        {            inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);        }     }}, 200);

Third MethodADD given code to activity tag in Manifest. It will show keyboard on launch, and set the first focus to your desire view.

android:windowSoftInputMode="stateVisible"


Hey I hope you are still looking for the answer as I found it when testing out my code. here is the code:

InputMethodManager imm = (InputMethodManager)_context.getSystemService(Context.INPUT_METHOD_SERVICE);imm.toggleSoftInput(0, 0);

Here is my question that was answered:android - show soft keyboard on demand


This worked with me on a phone with hard keyboard:

editText1.requestFocus();InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);          imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);