Open slackmoehrle opened 6 years ago
It looks like someone else had a similar issue: https://stackoverflow.com/questions/17703661/how-to-find-the-ppi-of-an-android-screen
My guess is that it's something in here https://github.com/cocos2d/cocos2d-x/blob/f2db054edbd674b03dc84569919f5493744af52a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java#L503
Maybe this is an issue with android DisplayMetrics ?
It seems it's because we use getMetrics
method in getDPI.
But since there are some devices which have virtual buttons in the bottom of screen, getMetrics
will not include the size in the area of virtual buttons.
I searched some articles on the internet, found that there is a new API called getRealMetrics
that will include the size of virtual buttons.
Yep, we need to modify the implementation of getDPI. I will try to reproduce it on some devices and try to fix it. Thanks for your feedback, @slackmoehrle .
@slackmoehrle , could you please add the link of this thread in the Engine forum?
Ok, I just hope that these issues (this and https://github.com/cocos2d/cocos2d-x/issues/9419) will be closed together.
From US forums:
I am trying to get the device ppi but it looks like on android it’s wrong.
I tried a nexus 4 which has 318 ppi but when I do getDpi it returns 320. I tried Samsung galaxy s7 and it returned 640 but it’s suppose to be 577.
It seems to work fine on ios…
Also I think it’s miss leading that it’s called getDpi for actually getting the ppi?