Getting the screen size in pixels

Start by getting a reference to the WindowManager. When in an Activity, you can use getWindowManager(), otherwise, use:

WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

Use the WindowManager to get the Display, then get the dimensions:

Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width, height;
if (Build.VERSION.SDK_INT >= 13) {
	width = size.x;
	height = size.y;
} else {
	width = display.getWidth();
	height = display.getHeight();
}