getSize() giving me errors
Method to get Display Size for all devices:
private static Point getDisplaySize(final Display display) {
Point point = new Point();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { // API LEVEL 13
display.getSize(point);
} else {
point.x = display.getWidth();
point.y = display.getHeight();
}
return point;
}
gettin Size:
WindowManager wm = ((WindowManager)context.getSystemService(context.WINDOW_SERVICE));
Display display = wm.getDefaultDisplay();
Point myPoint = getDisplaySize(display);
Log.i("***Size X::", String.valueOf(myPoint.x));
Log.i("***Size Y::", String.valueOf(myPoint.y));
This supports both older and newer devices:
private static Point getDisplaySize(final Display display) {
final Point point = new Point();
try {
display.getSize(point);
} catch (java.lang.NoSuchMethodError ignore) { // Older device
point.x = display.getWidth();
point.y = display.getHeight();
}
return point;
}