Search code examples
javaandroidandroid-edittextkeyboard

Keyboard shows up automatically when the app starts?


In my MainActivity, I've added an EditText. When the user opens the app, the keyboard automatically shows up to let the user type text, but my app shows ads in onCreate(), therefore I want to disable that automatic event, is that possible?


Solution

  • In the AndroidManifest.xml you can use the following settings:

    <activity android:name="com.your.package.ActivityName" 
            android:windowSoftInputMode="stateHidden"  />
    

    You can also try:

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
    

    You can find more details at this link.