I am porting an iOS app to Android. My app handles all iOS devices by detecting screen resolution at launch and then calling an appropriate sub-stack. I'm looking to do this for Android and 7 or 8 of the most popular devices. The dictionary says mobilePixelDensity should provide "Display Metrics" for Android, and a "2" or '1" on iOS. When I use this I am not getting "Metrics", but rather a "2", which is what I would expect on a Retina device. I presume this means the display (Galaxy Nexus emulator) is xhdpi. When I get the screenRect at launch, it reports 360X640. That device should be 720X1280. So if I factor in the mobilePixelDensity, then it makes sense. So I think I can rather easily figure out the proper resolution with this methodology.
I have two questions:
1. Has anyone found a better way to accomplish what I am attempting on Android? (I am not able to leverage res independence, so please no such suggestions).
2. Anyone have experience with mobilePixelDensity on Android? It does not appear, based on documentation, that it is delivering what it should. Or is it?
Comments and suggestions appreciated.
Android Multiple Devices and Resolutions
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Android Multiple Devices and Resolutions
I use the same amount of pixel on PC and on Android and works. I don't use pixel density.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Android Multiple Devices and Resolutions
It turns out that mobilePixelDensity is indeed functioning correctly. It yields the following values on Android devices:
240x320 low dpi = 0.75
320x480 medium dpi-= 1.0
480x800 high dpi =1.5
1280 x 720 extra high dpi = 2.0
The metrics from above (0.75, 1.0, 1.5, 2.0) are returned values from mobilePixelDensity
Starting with LC 6.5.1, logical and device pixels are now scaled according to the
systemPixelScale setting. If you wish to disable this automatic scaling, then you must set
the pixelScale property to “1.0”. This essentially brings the Android devices and
in particular handling of graphics into parity with the iPhoneUseDeviceResolution
functionality.
Credit goes to Neil in RunRev support for this insight.
240x320 low dpi = 0.75
320x480 medium dpi-= 1.0
480x800 high dpi =1.5
1280 x 720 extra high dpi = 2.0
The metrics from above (0.75, 1.0, 1.5, 2.0) are returned values from mobilePixelDensity
Starting with LC 6.5.1, logical and device pixels are now scaled according to the
systemPixelScale setting. If you wish to disable this automatic scaling, then you must set
the pixelScale property to “1.0”. This essentially brings the Android devices and
in particular handling of graphics into parity with the iPhoneUseDeviceResolution
functionality.
Credit goes to Neil in RunRev support for this insight.