I have an EditText in an Activity and I want it to be active and soft-keyboard be open when I open that Activity. Here is my xml for EditText:
<EditText
android:background="@null"
android:cursorVisible="true"
android:elegantTextHeight="true"
android:enabled="true"
android:focusable="true"
android:hint="Search"
android:id="@+id/editText11"
android:inputType="textNoSuggestions|textCapSentences"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:singleLine="true"
android:textColor="#000000"
android:textCursorDrawable="@null" />
and I have used android:windowSoftInputMode="stateVisible" for the activity in which I have this EditText.
The problem is, when I press back once, the keyboard does not hide(ideally it does in all other EditTexts) and when I press back again, it closes the Activity. On the first back press, I am not getting a call to onBackPressed() while on the second back press, I do. Why is this kind of behaviour is happening and how to resolve it?
Edit What I want is, if keyboard is open, pressing back should close the keyboard and if the keyboard is not open, then close the activity.