Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot create Android 4.0 AVD with system bar

Tags:

android

avd

Is there a way to create an android AVD with a system bar like in honeycomb? When I create any AVD I get "hard" keys to appear as part of the emulator and no system bar like in honeycomb. Anyway to get a system bar to show up?

like image 477
Andi Jay Avatar asked Oct 25 '11 16:10

Andi Jay


4 Answers

You can do this by creating a new AVD and setting its screen resolution to wxga720. This will make it a "tablet" device.

For those who are actually interested in what is going on here, by creating a device with wxga720 resolution a hardware property called Hardware Back/Home keys is created and set to no. Also, another property called Keyboard lid support is set to no. These two together are what actually get rid of the "hard keys".

like image 85
Kurtis Nusbaum Avatar answered Oct 16 '22 23:10

Kurtis Nusbaum


There is a bug in Android that sets the keyboard lid to 'yes' regardless of whether you type 'yes' or 'no'. You can look under your home directory's ".android" folder, look under "avds" then the AVD you craeted, and go edit the config.ini file to set it to 'no'

like image 34
Cheryl Avatar answered Oct 17 '22 00:10

Cheryl


Here's what worked for me, on both the WXGA720 skin and custom 1280x800 resolution:

Option A: Edit config.ini

  1. Navigate to the AVD directory (.android/avd/<name-of-avd>.avd/)
  2. Open config.ini in your desired text editor
  3. Set hw.lcd.density=160
  4. Save

Option B: Edit in Android SDK Manager (GUI)

  1. Click Tools | Manage AVDs...
  2. Select Android Virtual Device to edit
  3. Click Edit...
  4. Click the Value for the Abstracted LCD density property
  5. Enter 160
  6. Click Edit AVD to save

After editing the density, start the AVD and enjoy the Ice Cream Sandwich tablety goodness. :)

It seems like the logic in the emulator that determines whether to present a phone or tablet interface is based on the calculated physical size of the virtual device's screen, which is dependent on two parameters: screen size and pixel density.

Like others, I had used the built-in WXGA720 skin hoping to work with the tablet interface, and was disappointed to be presented with a phone interface in landscape orientation. I even tried a new device with a custom resolution of 1280x800 and set hw.mainKeys and hw.keyboard.lid in the config.ini to no avail.

The WXGA720 skin's default density of 320 produces a calculated screen size of 4.6" diagonal (4" x 2.25"), which I'm surmising is within the emulator's esoteric threshold for a phone device. Even the custom resolution of 1280x800, defaulting at a density of 240 and thereby sporting a whopping 6.3" diagonal (!), is rendered with a phone interface.

Some well-named default AVD skins in the SDK ("WXGA720-phone" & "WXGA720-tablet", e.g.) would help eliminate the confusion here. Perhaps we should nag Google.

like image 24
Stachre Avatar answered Oct 17 '22 00:10

Stachre


I spent some time looking for this and digged trough Android 4.0 source to figure how it works. This is what I found out:

  • Android decides whether to go into tablet mode using isTabletUI function. The function just checks if the screen is XLARGE. By further digging into the code I found that screen is detected as XLARGE if its larger then 800x600 at medium density. I've managed to make it run with systembar at 120 dpi with 600x450 resolution.
  • There apears to be no way of making Android Emulator behave like Galaxy Nexus, that is have Phone interface with status bar and systembar. It will either have status bar (phone ui) or system bar (tablet ui). In other words it appears Galaxy Nexus is not running vanilla version of ICS as I would have expected..
like image 26
Ivan Avatar answered Oct 16 '22 23:10

Ivan