Android show softkeyboard with showSoftInput is not working?

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


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 Method ADD 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"