I was trying to get the screen resolution of android phones,using this code
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDi
Here is how i did it:
Display dis = getWindowManager().getDefaultDisplay();
Point point= new Point();
dis.getSize(point);
int width = point.x;
int height = point.y;
When not in an Activity:
WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Before getSize was introduced (in API level 13), you could use the getWidth and getHeight methods that are now deprecated:
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth(); // deprecated
int height = display.getHeight(); // deprecated