I am getting display size using this function but i get wrong display size in this(moto G2,HTC E8 ,Moto E,Lg G2) device. but in my other device i got perfect size. how to I calculate this size?
private void getDefaultDisplay(WindowManager wm) {
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Display display = wm.getDefaultDisplay();
Point size = new Point();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
display.getSize(size);
CAMERA_WIDTH = size.x;
CAMERA_HEIGHT = size.y;
Log.d("Display", CAMERA_WIDTH + ":" + CAMERA_HEIGHT);
} else {
CAMERA_WIDTH = display.getWidth(); // deprecated
CAMERA_HEIGHT = display.getHeight();
}
}
device Name calcualted size : original size
moto G2 720x1184 : 720x1280
HTC E8 1080x1776 : 1080x1920
Moto E 540x888 : 540x960
LG G2 1080x1776 : 1080 x1920