5

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!

MiguelHincapieC
  • 5,445
  • 7
  • 41
  • 72
jstock
  • 116
  • 1
  • 8
  • "if I use a package name other then my released app's package name the correct metrics are returned" -- what do you mean? Do you mean if you change `applicationId` in `build.gradle`? Looking at the `ActivityThread` source, you may be able to disable this change by setting `android:anyDensity="false"` in `` in the manifest, though [they advise against that](http://developer.android.com/guide/practices/screens_support.html#DensityConsiderations). – CommonsWare Sep 16 '15 at 23:54
  • Correct, changing the `applicationId` in `build.grade` will cause the correct screen size to be returned from getWindowVisibleDisplayFrame. Setting `android: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). – jstock Sep 17 '15 at 03:53
  • "Correct, changing the applicationId in build.grade will cause the correct screen size to be returned from getWindowVisibleDisplayFrame" -- that is rather bizarre. The only reason I can think of that would have an impact here is if you are updating the original app in place, and something about that app (maybe in an earlier manifest?) is triggering the behavior. Have you tried a full uninstall/reinstall of the app with its original `applicationId`? – CommonsWare Sep 17 '15 at 09:55

2 Answers2

2

We finally found the answer to the Note 5 reducing the usable space for our app/game. It turned out Samsung is doing some optimization on the usable screen size for battery performance. The only way we found to use the true screen size of the display is by downloading Samsung's Game Tuner app and setting the mode to "Maximum Quality". It appears that without the Game Tuner app installed the default "Balanced Quality" is used, which results in the 1080p usable area.

https://play.google.com/store/apps/details?id=com.samsung.android.gametuner.thin&hl=en

jstock
  • 116
  • 1
  • 8
0

Try this

Point size = new Point();
WindowManager w = getWindowManager();

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    w.getDefaultDisplay().getSize(size);

    mWindowWidth = size.x;
    mWindowHeight = size.y;
} else {
    Display d = w.getDefaultDisplay();
    mWindowWidth = d.getWidth();
    mWindowHeight = d.getHeight();
}
BORSHEVIK
  • 794
  • 1
  • 8
  • 12