Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulating opening/closing the hardware keyboard in emulator

Tags:

android

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!

like image 736
LambergaR Avatar asked Jan 12 '10 09:01

LambergaR


1 Answers

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:

  1. Open the AVD Manager
  2. Select the AVD you want to edit
  3. Click on Edit... on the right
  4. In the Hardware section, click on New... on the right
  5. In the Property combo box select Keyboard support and click OK
  6. Again in the Hardware section, change the Keyboard support value column to "no"
  7. Finally click Edit AVD and exit the Manager.

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.

like image 70
Joe Avatar answered Sep 21 '22 13:09

Joe