I used the following method to get the screen size:
public static Point getScreenSize(Context context)
{
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
int w = wm.getDefaultDisplay().getWidth();
int h = wm.getDefaultDisplay().getHeight();
return new Point(w, h);
}
On my s6 ssung galaxy, this method returns 1080x1920 ... Although my device has a resolution of 1440x2560.
Why? Is there a better way to get a screen resolution that also works on newer phones?
EDIT
I need this method in the service! I have no view / activity for reference, only application context! And I need REAL pixels
source
share