Search code examples
androidandroid-studioandroid-softkeyboardandroid-9.0-pie

Keyboard doesn't show up when enter to activity in Android Pie (API-28)


I want to pop up the device keyboard when I enter to Email Login screen.

I declared the windowSoftInputMode to "stateVisible" in the AndroidManifest.xml file:

<activity
        android:name=".activities.EmailLoginActivity"
        android:launchMode="singleTask"
        android:screenOrientation="portrait"   
        android:windowSoftInputMode="stateVisible" />

I have followed this documentation.

Results:

On devices that run Android API up to 27, the keyboard is shown.

On devices that run the Android API 28, the keyboard is not shown.

Is it a bug in Android Pie?

Any suggestion?


Solution

  • Seems in Android Pie (API 28), it is not setting request focus in EditText automatically.

    So you have to set the requestFocus of your EditText either programmatically or in the XML file.

    your_layout.xml

    <EditText
            android:id="@+id/et_email"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/_20sdp"
            android:inputType="textEmailAddress"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">
    
            <requestFocus />
        </EditText>
    

    OR

    your_activity.java

    findViewById(R.id.et_email).requestFocus();