(Android) Find physical screen size programatically

By | July 27, 2014

This method will find out if screen is a tablet size.

You could of course make this even more corner case-compliant by getting the units dpi (dot per inch) and use the Pythagorean theorem to find the actual inch size of the diagonal. But this will probably suffice for most case.

	private boolean isLargeScreen() {
		DisplayMetrics metrics = new DisplayMetrics();
		// Get the density of the screen (dp)
		float density = metrics.density;		
		// Find out if the smallest of x/y is largeer than 600 (7" tablet. For 10" use 720)
		return Math.min(metrics.widthPixels / density,  metrics.heightPixels / density) > 600;

Leave a Reply

Your email address will not be published. Required fields are marked *