The Android soft keyboard does not trigger

advertisements

I have multiple EditText on my screen and one of them is focussed. The softkeyboard does not trigger as soon as the screen pops up. I want the soft keyboard to trigger as soon as the screen pops up. It works well if I don't implement the onFocusChangeListener(). However I need the onFocusChangeListener() to detect which editText is focused. I have tried setting setFocusable(true) and setFocusableInTouchMode(true). Also i don't want to modify the android:windowSoftInputMode property in AndroidMenifest.xml. I have the following criteria :

  1. onFocusChangeListener implemented (to detect which edittext is focused)
  2. No modifications in AndroidMenifest.xml

Here is my code snippet

final InputMethodManager inputMethodManager =  (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

    mInput.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean hasFocus) {
            mIsFocused = hasFocus;
            if(hasFocus)
                inputMethodManager.showSoftInput(mInput, InputMethodManager.SHOW_IMPLICIT);

        }
    });

Any suggestions ?


You can open softkeyboard programmatically

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);