Snatching Android's biggest secret: the native screen resolution

Dear all,

in order to display high-quality true-type fonts etc., my App window
must map to the physical pixels exactly.

Unfortunately, Google seems to do everything possible to keep the native
resolution a secret, including making false claims in the documentation.

So when I create a device with resolution WVGA854 (480x854 pixels) in
the Android emulator, Android reports to SDL that the screen resolution
is actually 320x519, so SDL creates a window and corresponding texture
with 320x519 pixels. When updating the screen, the texture is scaled by
a factor 1.5 to 480x778 (the remaining 76 vertical pixels (854-778) are
used by the status bar + application name), and all fonts etc. look ugly.

So far, I googled for hours, all attempts to get the real display
resolution failed.

I used for example:

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
Log.v(“Metrics”, “widthPixels=”+metrics.widthPixels);
Log.v(“Metrics”, “heightPixels=”+metrics.heightPixels);
Log.v(“Metrics”, “xdpi=”+metrics.xdpi);
Log.v(“Metrics”, “ydpi=”+metrics.ydpi);

This gives:

V/Metrics ( 1326): widthPixels=320
V/Metrics ( 1326): heightPixels=569
V/Metrics ( 1326): xdpi=160.0
V/Metrics ( 1326): ydpi=160.0

(note that heightPixels is without status bars now)

I also tried:

Log.v(“SDL”, “getWidth:”+getWindowManager().getDefaultDisplay().getWidth());
Log.v(“SDL”,
“getHeight:”+getWindowManager().getDefaultDisplay().getHeight());

This yields the same result:

V/SDL ( 1450): getWidth:320
V/SDL ( 1450): getHeight:569

In short, does anyone have an idea how to determine the real display
resolution and get crispy, unscaled graphics on screen?

Many thanks,
Elmar

2012/8/10 Elmar Krieger

Dear all,

in order to display high-quality true-type fonts etc., my App window must
map to the physical pixels exactly.

Unfortunately, Google seems to do everything possible to keep the native
resolution a secret, including making false claims in the documentation.

So when I create a device with resolution WVGA854 (480x854 pixels) in the
Android emulator, Android reports to SDL that the screen resolution is
actually 320x519, so SDL creates a window and corresponding texture with
320x519 pixels. When updating the screen, the texture is scaled by a factor
1.5 to 480x778 (the remaining 76 vertical pixels (854-778) are used by the
status bar + application name), and all fonts etc. look ugly.

So far, I googled for hours, all attempts to get the real display
resolution failed.

Have you tried this in a real device? I get the correct window size from
SDL on every device I’ve tried.–
Gabriel.

So when I create a device with resolution WVGA854 (480x854 pixels) in
the Android emulator, Android reports to SDL that the screen resolution
is actually 320x519, so SDL creates a window and corresponding texture
with 320x519 pixels. When updating the screen, the texture is scaled by
a factor 1.5 to 480x778 (the remaining 76 vertical pixels (854-778) are
used by the status bar + application name), and all fonts etc. look ugly.

OK, problem solved. Maybe someone can add the following text to
README.android to save others some hours of fiddling:

Replace

AndroidManifest.xml - package manifest, do not modify

with

AndroidManifest.xml - package manifest, most likely needs to be
adapted for your app

And:================================================================================
AndroidManifest.xml

The file AndroidManifest.xml presents essential information about the
application to the Android system and the Google Play store. Here are
some of the most critical parameters to add between and
:

where ‘X’ is the minimum SDK version (=API level) supported, e.g. "9"
for Android 2.3. If this parameter is missing or set too low, your app
will be downscaled (e.g. if you create a device with resolution 480x800
in the Android emulator, SDL will only create a window with resolution
320x533).

If your app wants to write to the SD card, you need:

To connect to the Internet, you need:

And if you want your SDL app to run fullscreen (without title bar), you
need to add this parameter to the activity tag:

A full description of the manifest file can be found here:

http://developer.android.com/guide/topics/manifest/manifest-intro.html

CU,
Elmar

So far, I googled for hours, all attempts to get the real display
resolution failed.

I used for example:

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
Log.v(“Metrics”, “widthPixels=”+metrics.widthPixels);
Log.v(“Metrics”, “heightPixels=”+metrics.heightPixels);
Log.v(“Metrics”, “xdpi=”+metrics.xdpi);
Log.v(“Metrics”, “ydpi=”+metrics.ydpi);

This gives:

V/Metrics ( 1326): widthPixels=320
V/Metrics ( 1326): heightPixels=569
V/Metrics ( 1326): xdpi=160.0
V/Metrics ( 1326): ydpi=160.0

(note that heightPixels is without status bars now)

I also tried:

Log.v(“SDL”,
“getWidth:”+getWindowManager().getDefaultDisplay().getWidth());
Log.v(“SDL”,
“getHeight:”+getWindowManager().getDefaultDisplay().getHeight());

This yields the same result:

V/SDL ( 1450): getWidth:320
V/SDL ( 1450): getHeight:569

In short, does anyone have an idea how to determine the real display
resolution and get crispy, unscaled graphics on screen?

Many thanks,
Elmar


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Elmar Krieger, PhD
YASARA Biosciences GmbH & CMBI Outstation Austria
Wagramer Strasse 25/3/45
1220 Vienna
Austria/Europe
www.YASARA.org