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

525 Views Asked by At

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?

2

There are 2 best solutions below

0
cyanide On BEST ANSWER

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);
}
2
navylover On

run below command:

npm i cordova-plugin-multidex

which adds the multidex flag to Android builds by amending the AndroidManifest.xml generated by Cordova

Here is a ref about multidex