Here you can find the source of getRealScreenDimensions(Context context)
public static int[] getRealScreenDimensions(Context context)
//package com.java2s; import android.content.Context; import android.util.DisplayMetrics; import android.view.Display; import android.view.WindowManager; public class Main { public static int[] getRealScreenDimensions(Context context) { WindowManager wm = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getRealMetrics(metrics); return new int[] { metrics.widthPixels, metrics.heightPixels }; }//from w w w . ja va 2 s. c om }