Here you can find the source of getScreenHeight(Context context)
public static int getScreenHeight(Context context)
//package com.java2s; import android.content.Context; import android.content.res.Configuration; import android.util.DisplayMetrics; import android.util.Log; import android.view.WindowManager; public class Main { public static final String TAG = "CLDeviceUtil"; public static int getScreenHeight(Context context) { int screenSizeOne = -1; int screenSizeTwo = -1; if (screenSizeOne <= 0 || screenSizeTwo <= 0) { DisplayMetrics dm = new DisplayMetrics(); WindowManager wm = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(dm); screenSizeOne = dm.widthPixels; screenSizeTwo = dm.heightPixels; }//from w w w . j ava 2 s. c o m Configuration conf = context.getResources().getConfiguration(); switch (conf.orientation) { case Configuration.ORIENTATION_LANDSCAPE: return screenSizeOne < screenSizeTwo ? screenSizeOne : screenSizeTwo; case Configuration.ORIENTATION_PORTRAIT: return screenSizeOne > screenSizeTwo ? screenSizeOne : screenSizeTwo; default: Log.e(TAG, "can't get screen height!"); } return screenSizeOne; } }