How to keep soft keyboard from opening on activity launch in Android?

I know this is old but maybe it will help someone in the future...

I haven't seen anyone suggest "stateHidden"

From the Android docs - android:windowSoftInputMode

Your manifest file would look like:

<activity
    ...
    android:windowSoftInputMode="stateHidden|adjustResize"
    ...
>

You can use the following line of code to make sure the keyboard only pops up when a user clicks into an EditText

Java

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 

Kotlin

window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)

And

You need to add

android:windowSoftInputMode="adjustResize"

to your activity tag in the AndroidManifest.xml file.

Tags:

Android