Here you can find the source of getScreenSize(Context context)
public static int[] getScreenSize(Context context)
//package com.java2s; import android.content.Context; import android.util.DisplayMetrics; import android.view.WindowManager; public class Main { public static int[] getScreenSize(Context context) { int[] ints = { 0, 0 }; DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager windowManager = ((WindowManager) context .getSystemService(Context.WINDOW_SERVICE)); windowManager.getDefaultDisplay().getMetrics(displayMetrics); ints[0] = displayMetrics.widthPixels; ints[1] = displayMetrics.heightPixels; return ints; }//from w w w. j a va2s .c om }