@gmayer wrote:
Hello.
There are a few threads about issues getting screen size and DPI on Android.Here is an issue from 2017 that appears to be still open.
In addition to the wrong DPI, I’m not even getting the correct width and height for my device.
Samsung A8 - from Droid Info app, the internet, and screenshots, my device is
2220 x 1080 (landscape width + height)The following calls in code:
float width = director->getWinSize().width; float height = director->getWinSize().height; Size sizeInPixles = director->getWinSizeInPixels(); Size visibleSize = director->getVisibleSize();
all give me 1665 x 810
Also,
float dpi = (float)(Device::getDPI());
reports 360, when it should be 480.
The situation is somewhat better on iOS. iPad3 and iPhone5s give correct width, height, and dpi, but iPad Mini (original) has correct width, height, but WRONG dpi – this makes the calculation for screen size give a result almost the same as a 9.7" screen, instead of the 7" it actually is.
I saw this workaround for Android dpi:
but that appears to be java code. Not sure how to expose that to C++.
Could this be fixed please!?
I’m on the verge of shipping and important update to my game, and am blocked by this, because there are a few decisions I want to make in code at startup based on physical screen size, but I have no reliable way of doing it!
thanks
Greg
Posts: 1
Participants: 1