views:

31

answers:

1

I want to open soft keyboard while starting an activity.

The activity contains nothing as its element. I just need to open soft keyboard on the launch.

I've tried with

<activity android:windowSoftInputMode="stateAlwaysVisible|stateVisible|adjustResize" but it didn't work.

Also tried with

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

but it didn't work as well

i'm using emulator to run the code

Thanks in advance

A: 

HI,
you could try :

 InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(flags, InputMethodManager.SHOW_IMPLICIT);

This will not open the keyboard if there is a physical one available and opened.(flags can be 0 if there is nothing.)

Sephy