Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 206
Elnatan Derech Avatar asked Aug 21 '18 13:08

Elnatan Derech


1 Answers

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();
like image 131
Viraj Patel Avatar answered Oct 07 '22 00:10

Viraj Patel