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

Rites
  • 2,242
  • 5
  • 28
  • 44

3 Answers3

2

Have you tried

<activity 
android:windowSoftInputMode="stateVisible|adjustPan">

?

grine4ka
  • 2,878
  • 1
  • 19
  • 29
0

try the below code hope it helps

<activity android:windowSoftInputMode="adjustPan">

for more information regarding this Read

karan
  • 8,637
  • 3
  • 41
  • 78
0

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
  • 50,022
  • 30
  • 123
  • 131