简体   繁体   中英

Cannot create Android 4.0 AVD with system bar

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?

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".

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'

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", eg) would help eliminate the confusion here. Perhaps we should nag Google.

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..

Actually it's pretty easy, just go to the AVD Manager (the program that manages the emulator virtual images), select the Android 4 image, then add the property "Hardware Back/Home keys" and set it to "no

(from http://www.dandandin.net/how-to-show-the-new-softkeys-in-the-ice-cream-sandwich-emulator )

You're sure you picked the right API level too? That one got me the first time, I thought I clicked on the right one, but I hadn't.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM