Getting real screen resolution on Samsung Galaxy S7

I’m trying to get the real resolution of the device, here it’s Samsung Galaxy S7. But the problem exists also on SGS 6.

I’ve tried using Java’s DisplayMetrics:

DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int width=dm.widthPixels;
int height=dm.heightPixels;

-this returns 1920x1080.

Tried Unreal Engine’s:

FPlatformMisc::GetHardwareWindow()
GEngine->GameViewport->Viewport->GetSizeXY()

-both wrong.

The desired result is 2560x1440. Any ideas?

I’m running into the exact same issue on a Samsung Galaxy S6 (same native resolution). Unreal Engine is actually rendering at 1920x1080 and I’m pretty sure it thinks that is the native resolution. Does anyone have any ideas?

This works for me:

DisplayMetrics dm = getResources().getDisplayMetrics();
int width = dm.widthPixels;
int height = dm.heightPixels;

Well, for me it doesn’t - resolution returned 1920x1080. Tested both on SGS6 and SGS7. Still, thanks for this, there was no need to create new DisplayMetrics.

For some reason it works fine for me. Where are you calling this? In OnCreate or in a separate function?
Also, check this out. You could be getting Display Independent Pixels instead of actual pixels.

I’m doing this in a separate function that is called in OnCreate. Still no luck.

int width = (int) Math.ceil(dm.widthPixels * (dm.densityDpi / 160.0));
int height = (int) Math.ceil(dm.heightPixels * (dm.densityDpi / 160.0));

^ This gave me 5760x3240 ^

Same thing using dm.density instead of densityDpi / 160.0.

Not sure if it changes anything, but I call my code in another function, not in OnCreate. If its possible maybe try this?