Show soft keyboard when Activity starts

Al. picture Al. · Mar 18, 2010 · Viewed 47.2k times · Source

I have 2 activities, A and B. When A starts, it checks for a condition and if true, it calls startActivityForResult() to start B. B only takes text input so it makes sense for the soft keyboard to automatically pop up when B start. When the activity starts, the EditText already has focus and it ready for input.

The problem is that the keyboard never shows up, even with windowSoftInputMode="stateAlwaysVisible" set in the manifest under the <activity> tag for B. I also tried with the value set to stateVisible. Since it doesn't show up automatically, I have to tap the EditText to make it show.

Anyone know what the solution might be?

Answer

Leo picture Leo · Jan 24, 2011

What worked best for me is in Android Manifest for activity B adding

android:windowSoftInputMode="stateVisible"

Hope that helps for you as well.