Java tutorial
//package com.java2s; //License from project: Apache License import android.app.Activity; import android.util.DisplayMetrics; import android.view.Display; import android.view.WindowManager; public class Main { public static int getScreenHeightDP(Activity activity) { WindowManager wm = activity.getWindowManager(); //wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Display dp = wm.getDefaultDisplay(); DisplayMetrics dm = new DisplayMetrics(); dp.getMetrics(dm); float res = dm.heightPixels / dm.density; return (int) res; } }