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.
[java]
private boolean isLargeScreen() {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
// 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;
}
[/java]
Leave a Reply