title: kotlin hide soft keyboard on Android 8
body: <p>We are trying to hide the soft keyboard during development. Translated we do not ever want to see it. Here is the configuration Nexus 9 API 28 Project SDK 26 Project is Kotlin Here is the code for the Manifest</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.androidstackoverflow.devconstraint"
  android:windowSoftInputMode="stateAlwaysHidden"&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
  
      android:theme="@style/AppTheme"&gt;
      &lt;activity android:name=".MainActivity"
          android:windowSoftInputMode="stateAlwaysHidden"&gt;
  
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity android:name=".LayOutActivity"
          android:windowSoftInputMode="stateAlwaysHidden"&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>We have tried every line of code in this SO Question
  <a href="https://stackoverflow.com/questions/49372917/android-hide-keyboard-on-android-8">Question</a></p>
  
  <p>code in LayOutActivity</p>
  
  <pre><code>open class LayOutActivity : AppCompatActivity() {
  
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_lay_out)
      this.window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
      val view = currentFocus
      //if (view != null) {
          //val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
          //imm.hideSoftInputFromWindow(view.windowToken, 0)
      //}
      //val imm: InputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
      //if (imm.isActive)
      //imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0)
  
      //hideSoftKeyboard(view = null)
  
  
      //UIHelper.hideSoftKeyboard(activity = Activity())
          doALL()
  
  
  }
  
  //fun hideSoftKeyboard(view: View?) {
      //val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
      //inputMethodManager.hideSoftInputFromWindow(view?.windowToken, 0)
  //}
  fun doALL(){
      //UIHelper.hideSoftKeyboard(activity = Activity())
      UIHelper.hideSoftKeyboard(view = null)
      UIHelper.hideKeyboard(this,etOne)
      etOne.setText("I have new Text")
  }
  
  
  object UIHelper {
  
      fun hideSoftKeyboard(activity: Activity?) {
          if (activity != null) {
              val inputManager = activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
              if (activity.currentFocus != null &amp;&amp; inputManager != null) {
                  inputManager.hideSoftInputFromWindow(activity.currentFocus!!.windowToken, 0)
                  inputManager.hideSoftInputFromInputMethod(activity.currentFocus!!.windowToken, 0)
              }
          }
      }
  
      fun hideSoftKeyboard(view: View?) {
          if (view != null) {
              val inputManager = view!!.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
              inputManager?.hideSoftInputFromWindow(view!!.getWindowToken(), 0)
          }
      }
  
      fun hideKeyboard(activityContext: Context, editText: EditText) {
          editText.requestFocus()
          Handler().postDelayed({
              val inputMethodManager = activityContext.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
              inputMethodManager.showSoftInput(editText, InputMethodManager.HIDE_IMPLICIT_ONLY)
          }, 250)
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>We just want to know how to keep the soft keyboard hidden 
  We have used the one line of code in the LayOutActivity before and it worked
  Is this a new issue with Android 8 or with Kotlin ?
  here is our one line that worked</p>
  
  <pre><code>this.window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
  </code></pre>