Is there a way to simulate opening/closing the 'hardware' keyboard in the emulator? I have to test some changes that I capture using getResources().getConfiguration().keyboardHidden and this would help a fair lot :)
Thank you in advance!
To add to Samuh's explanation (which I didn't know -- good to know that I can still simulate opening/closing the hardware keyboard by changing orientation), you can test the difference between landscape with no keyboard and landscape with keyboard open, by changing the hardware configuration of the emulator's AVD: The AVD can be configured to either have a hardware keyboard or not. If your emulator has no hardware keyboard, the soft keyboard appears as you would expect, and going to landscape mode should appear as it would in landscape mode on a phone with no keyboard.
To configure the emulator AVD to act as if it has no hardware keyboard, in the AVD & SDK Manager tool, click "New" to add a new AVD, select your desired SDK level and other options, and under the Hardware section, add a new property for "Keyboard support", and set it to "No". In the AVD emulator "Details" dialog, this will show up as "hw.keyboard = no".
Note: you can also modify an existing AVD to toggle its keyboard support by:
Alternatively, you can also edit the <avd path>/avd/<AVD device name>.avd/config.ini
file, and changing the hw.keyboard
entry to yes or no. On Mac and Linux, is generally ~/.android/
, and on Windows /Users/<user-name>/.android/
.
Based on Samuh's answer, that means you can check the behavior of the phone being in landscape mode with keyboard open (emulator has a hardware keyboard configured), or in landscape mode with no keyboard (emulator is configured with no keyboard). Two minor frustrations with this are 1) you can't necessarily emulate how it will look in landscape mode on a device that has a hardware keyboard, but the keyboard is hidden (if I understand correctly), and 2) you would have to run two separate emulators or at least two AVDs booted separately, in order to test those two different cases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With