Search code examples
androidandroid-softkeyboardinstant

"windowSoftInputMode=stateHidden" doesn't work for Instant Run


Recently I've found that despite windowSoftInputMode=stateHidden the soft keyboard appears at start of activity when the app is run from Google Play store as Instant Run (Try Now), however the Instant Run compilation works all right when installed on device through ADB.

Is there a way to get around it?


Solution

  • Couldn't find anything better than set all EditText views not focusable and then focusable again. Something like that:

    if (BuildConfig.FLAVOR.contains("instant")) {
       final View myEditTextView = findViewById(R.id.myEditTextViewId);
       myEditTextView.setFocusableInTouchMode(false);
       myEditTextView.postDelayed(new Runnable() {
          @Override
          public void run() {
              myEditTextView.setFocusableInTouchMode(true);
          }
       }, 500);
    }