I created an app that relies on some screen metrics to function. It works great on all devices, except for the Galaxy Note 5. On the note 5 it reports the screen size of 1080x1920 while the screen is actually 1440x2560. I also see the following message in logcat:
"ActivityThread﹕ Switching default density from 560 to 420"
I'm finding the screen size by calling getWindowVisibleDisplayFrame in the following code:
Rect usable_rect = new Rect();
Window window = activity.getWindow();
window.getDecorView().getWindowVisibleDisplayFrame(usable_rect);
One other odd observation, if I use a package name other then my released app's package name the correct metrics are returned. Please help!
applicationId
inbuild.gradle
? Looking at theActivityThread
source, you may be able to disable this change by settingandroid:anyDensity="false"
in<supports-screens>
in the manifest, though they advise against that. – SowellapplicationId
inbuild.grade
will cause the correct screen size to be returned from getWindowVisibleDisplayFrame. Settingandroid:anyDensity="false"
didn't change what was returned by getWindowVisibleDisplayFrame. It did cause the logcat message to go away and changed the DisplayMetrics's density to 0.75 (very wrong). – MidcourseapplicationId
? – Sowell