Android softkeyboard never shows up in emulator
Solution 1
You need to make sure that your emulator is not set to use a hardware keyboard. This can be done by choosing Edit
on a selected emulator in the AVD. Then uncheck the Hardware keyboard present
setting.
You could also try using a different emulator, such as Genymotion. It supports full hardware acceleration (multi-core CPU as well as GPU) and runs much faster than any of the android emulator images. If you use Genymotion you will need to disable the hardware keyboard within Android (see below for details).
To disable hardware keyboard in Genymotion:
Go to Settings
-> Language & input
and open the Default
item under Keyboard & Input Methods
. There is a Hardware
setting that you can toggle on/off. When it is on you use your physical keyboard and when it is off the standard soft keyboard should pop-up whenever a text field gets focus.
Screenshots for Genymotion settings:
Solution 2
In version 2.1.1 - click on your virtual device settings - then select "use virtual keyboard for typing" checkbox.
Solution 3
The method for enabling the on-screen soft keyboard for Android Studio 2+ Emulators depends on the API level of the emulator. I have tested the various methods starting with API 15 and have recorded the steps below.
[A] APIs 15, 17, 19 and 21.
The following steps will enabled the on-screen soft keyboard but will disable the ability to enter text and interact with the AVD using the hardware computer keyboard.
- In Android Virtual Device Manager (AVD), click the edit action for the device you wish to work with
- Click Show Advanced Settings and scroll right down to the bottom of the page to the "Keyboard" section
- Uncheck the "Enable keyboard input" option
[B] API 22
The soft keyboard is displayed no matter what you do with the hardware keyboard settings. If you wish to enable hardware keyboard support alongside the soft keyboard then,
- In AVD, click the edit action for the device you wish to work with
- Click Show Advanced Settings and scroll right down to the bottom of the page to the "Keyboard" section
- Check the "Enable keyboard input" option
[C] API 23
If you wish to use the hardware and soft keyboard then...
- Follow [B] steps 1 to 3
- On the virtual device, Launch Settings, then select Language and input / Current Keyboard
- Enable Hardware - Show input method
If you don't need the hardware keyboard, in AVD advanced settings, uncheck the "Enable keyboard input" option. You won't need to change any settings on the virtual device.
[D] APIs 24 and 25
- Follow [B] steps 1 to 3 above, checking or unchecking the "Enable keyboard input" option depending on whether you want to enable the hardqare keyboard.
- On the virtual device, Launch Settings, then select Language and input / Physical Keyboard
- Enable "Show virtual keyboard"
If the Enable keyboard input option was selected in the AVD then you will now be able to use both hard and soft keyboard inputs. If you unchecked the option in the AVD the soft keyboard will be displayed regardless.
[E] API 26
Exactly the same as [D] APIs 24 and 25 except you need to navigate through an additional "System" menu level in the device settings before you get to Language and input / Physical Keyboard
Solution 4
There are two places to deselect hardware keyboard in AS 1.1.0. This one isn't sufficient:
Must do this (click Tools | Android | AVD Manager
; then create new or edit old AVD and then click Show Advanced Settings
; scroll down and clear Enable keyboard input
):
Solution 5
To show:
EditText editText = (EditText) findViewById(R.id.myEdit);
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// only will trigger it if no physical keyboard is open
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
And to hide:
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(editText.getWindowToken(), 0);
Just try this one....
Related videos on Youtube
Andrey Chernukha
Updated on December 27, 2021Comments
-
Andrey Chernukha over 2 years
I'm new to Android. I've spent two hours already for searching. Whatever i try softkeyboard is never shown for my
EditText
. I create it simply:EditText editText = (EditText)findViewById(R.id.editText);
I tried:
editText.requestFocus();//i tried without this line too InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
and:
editText.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT); } });
i also tried:
getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
i tried putting this line into
AndroidManifest.xml
file:android:windowSoftInputMode="stateVisible|adjustResize"
but all in vain. It just never shows. What am i missing?
-
Niranj Patel almost 11 yearsis keyboard opening in any other application?
-
Aravin almost 11 yearstry this replace imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT); this to imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
-
Andrey Chernukha almost 11 years@CapDroid no, unfortunately. i tried in another application but still no luck
-
Andrey Chernukha almost 11 years@Aravinth still doesn't work
-
Aravin almost 11 yearsAre you using emulator or device.
-
Niranj Patel almost 11 years@AndreyChernukha using AVD manager add a hardware property Keyboard support and set it to true.
-
-
Andrey Chernukha almost 11 yearsit didn't help, unfortunately
-
FarhaSameer786 almost 11 yearsInputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);...try this
-
FarhaSameer786 almost 11 years@Andrey Chernukha-i think your emulator does not support softkeyboard or hardware of emulator not working properly.....
-
Andrey Chernukha almost 11 yearsFinally! Thank you very much. I wish i could upvote your answer twice. As for Genymotion - i spent a day once trying to setup it but it didn't work. I couldn't even write to their support
-
free3dom almost 11 yearsGlad to help :) As for Genymotion, they are constantly improving, but it is still preview/beta. However, since I started using it I haven't had a single problem. Could be that I just started with it once they had sorted out most of the problems - or I'm just lucky :). That said, the android emulator(s) do give more variation though, so I still use them for testing compatibility.
-
Michele over 10 yearsThat's great, now I got virtual keyboard! But I have a EditText with android:inputType="numberDecimal"> and virtualkeyboard doesn't write numbers (it write them only if I write a letter before them). Spell checker is already off...
-
free3dom over 10 yearsHave a look here for possible solutions.
-
IgorGanapolsky almost 10 years@free3dom ~"open the Default item under Keyboard & Input Methods" What is that? I don't see that item.
-
free3dom almost 10 years@Igor - that is only when using the Genymotion emulator, and it is still there in the latest version (v2.2.2). If that is what you are using just follow the instructions to get to it. I will add a screenshot to the answer, for clarity. Also see the answer by
Sharif
for an alternate method. -
IgorGanapolsky almost 10 yearsI guess it depends on Android target API. It doesn't show up in 4.1.1.
-
Tim Boland over 9 yearsWhen I switch Hardware Physical Keyboard to Off...it dosent persist when you close it...it only stays Off for the current session...I have to reset it everytime I open the emulator...is there anyway to persistently switch this setting Off or On?
-
GregM almost 9 yearsI spent time finding this solution because the scrolling indicator is normally gone and only shows up once you start scrolling. I would recommend that if a view is scrollable to have some indication of that possibility visually.
-
Evgenii over 8 yearsDoes not work for me in Android Studio. I uncheck the "Enable keyboard input" but the emulator still does NOT show the software keyboard.
-
DSlomer64 over 8 yearsYou only mentioned one "uncheck". The other is "Has hardware keyboard", as shown--and you probably already cleared it, too. Maybe try a different virtual device? I've found the AS emulator to be pretty hard to tolerate. Slow to load, quirks like this.... Good luck.