If you want the display dimensions in pixels you can use this code:
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
Then you can add condition that compares the height to satisfy your needs.
In inches:
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
double x = Math.pow(dm.widthPixels/dm.xdpi,2);
double y = Math.pow(dm.heightPixels/dm.ydpi,2);
double screenInches = Math.sqrt(x+y);
Log.d("debug","Screen inches : " + screenInches);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…