I would like to open the soft keyboard on when the Activity starts and I found that
android:windowSoftInputMode="stateVisible"
doesn’t work.
To make sure, I created a new project (the default “Hello world”) and did the following:
- added the windowSoftInputMode to the manifest.
- After that didn’t work, I added an EditView field to the layout
- After that didn’t work, I added
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
to the onCreate procedure.
I compiled it with Android2.3.3 and tried to run it on my Galaxy S2 device and the Android4 emulator
and still – no keyboard.
My manifest file:
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk android:minSdkVersion="9" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
<activity
android:name=".HelloworldActivity"
android:label="@string/app_name"
android:windowSoftInputMode="stateVisible">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
My main.xml layout:
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<requestFocus />
</EditText>
My code:
public class HelloworldActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
}
Do you use the default android keyboard? If you do, try it on a different device, I know it has some issues