Code example for Point

Methods: set

	public static Point getScreenSize(Context context) {
		Point ret = new Point();
		WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
		Display display = windowManager.getDefaultDisplay();
		// TODO: getWidth(), getHeight(), and getOrientation() are deprecated in API 13 in favor of getSize() and getRotation(). 
		ret.set(display.getWidth(), display.getHeight());
		return ret;
	public static void printDebugInfo(Context context) {
		// Print screen dimensions. 
		// Huawei Comet: Port: PX=240x320  DP=320x427, Land: PX=320x240 DP=427x320 
		// Galaxy Nexus: Port: PX=720x1184 DP=360x592, Land: PX=1196x720 DP=598x360 
		// Nexus 7:      Port: PX=800x1205 DP=601x905, Land: PX=1280x736 DP=962x553 
		Point point = Util.getScreenSize(context);
		Log.e("Screen size: PX=%dx%d DP=%dx%d", point.x, point.y, Util.pixelsToDips(context, point.x), Util.pixelsToDips(context, point.y));
Experience pair programming with AI  Get Codota for Java