27

We're trying to emulate devices with the new density of 320 dpi in Android 2.3 - such as Archos 101, and we can't seem to be able to define an emulator with such density, even after downloading the latest 2.3 sdk.

I would really appreciate some ideas on this one :)

Many thanks!

alain.janinm
  • 19,951
  • 10
  • 65
  • 112
LB_
  • 271
  • 1
  • 3
  • 3

4 Answers4

72

That is quite simple.

Modify the attribute hw.lcd.density=320 at avd config file: /Users/yourUserName/.android/avd/CustomDevice_API_19.avd/config.ini, and reboot your virtual device. I'm already test it, and it works to me!

Warnning: Make sure you set the correct density, otherwise you will receive an error: qemu: available lcd densities are: 120, 160, 213, 240, 280, 320, 360, 400, 420, 480, 560, 640

BTW my Android SDK Tools version is 25.2.5.

codezjx
  • 9,012
  • 5
  • 47
  • 57
  • worked perfectly. thanks! I had done the calculations and set the screen size in inches to what should have triggered 213dp but it was choosing 240 instead. Editing `config.ini` fixed that and now my emulator exactly matches the tablet I'm developing for. – gMale Jun 01 '17 at 15:27
  • awesome, worked, now I can simulate my device on emulator, exactly! – AVEbrahimi Sep 24 '17 at 12:24
  • 1
    Note to Linux user: the location is at /home/youruser/.android/avd/customdeviceavd/config.ini – aardbol Aug 21 '18 at 16:18
9

In the AVD manager if you choose a Built-in skin then the Abstracted LCD density is ignored and it will set the density as described here:

Emulator Skins (from http://developer.android.com/tools/revisions/platforms.html)

The downloadable platform includes the following emulator skins:

  • QVGA (240x320, low density, small screen)
  • WQVGA400 (240x400, low density, normal screen)
  • WQVGA432 (240x432, low density, normal screen)
  • HVGA (320x480, medium density, normal screen)
  • WVGA800 (480x800, high density, normal screen)
  • WVGA854 (480x854 high density, normal screen)
  • WXGA720 (1280x720, extra-high density, normal screen)
  • WSVGA (1024x600, medium density, large screen)
  • WXGA800-7in (1280x800, high density, large screen) new
  • WXGA800 (1280x800, medium density, xlarge screen)

If you wish to set your own Abstracted LCD density you'll need to define your own resolution manually by clicking the Resolution radio button.

Here's some code you can use to test this:

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int density = metrics.densityDpi;
    if (density == DisplayMetrics.DENSITY_HIGH) {
        Toast.makeText(this, "DENSITY_HIGH... Density is " + String.valueOf(density),  Toast.LENGTH_LONG).show();
    }
    else if (density == DisplayMetrics.DENSITY_MEDIUM) {
        Toast.makeText(this, "DENSITY_MEDIUM... Density is " + String.valueOf(density),  Toast.LENGTH_LONG).show();
    }
    else if (density == DisplayMetrics.DENSITY_LOW) {
        Toast.makeText(this, "DENSITY_LOW... Density is " + String.valueOf(density),  Toast.LENGTH_LONG).show();
    }
    else {
        Toast.makeText(this, "Density is neither HIGH, MEDIUM OR LOW.  Density is " + String.valueOf(density),  Toast.LENGTH_LONG).show();
    }
j0k
  • 22,600
  • 28
  • 79
  • 90
seb
  • 429
  • 4
  • 7
3

You can always define a custom density and resolution for your virtual devices.

If you are using Eclipse go to Window - Android SDK and AVD Manager, there hit the New button, enter a name and select the SDK version, hit the Resolution option down in the Skin section and set the resolution you need. In the Hardware section edit the default option ABstracted LCD Density to your desired value and hit the Create AVD button.

When you hit the Start button in the AVD Manager then you get a popup window where you can select Scale display to real size. There you have to set the devices real screen size and your monitors dpi. You can hit the question mark to the right of that input field and let the calculator calculate it for you based on your monitors size.

Octavian Helm
  • 39,405
  • 19
  • 98
  • 102
  • Thank you for your response . Sadly, we already tried setting the density to 320dpi inside the AVD manager, yet in the emulator it is somehow set to 240dpi . I think I read somewhere about this issue and I hoped that maybe there is a workaround or a possible fix for this, since this is quite a new problem. – LB_ Jan 25 '11 at 10:24
  • Interesting. I have not read about this issue yet. Could you please try to find and post that link? – Octavian Helm Jan 25 '11 at 10:51
  • 1
    I succeeded to find such a post yesterday without giving much time for it , yet sadly now I can't seem to find it . I think it was inside the official android developers google groups . In any case , my code of getting the density is as follows, and it always returns 240 for the new screen profile of Archos : DisplayMetrics displayMetrics=new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); final int density=displayMetrics.densityDpi; – LB_ Jan 25 '11 at 12:17
2

From what I understand Android categorises the screen size and density so I think it treats 240dpi the same as 320dpi, i.e. it's high density. There is also a next option up which is extra high density. I found this information in the Android developer reference see http://developer.android.com/guide/topics/fundamentals.html and the section towards the bottom called Declaring application requirements. I may be totally wrong but thought it worth a shout.