Java tutorial
//package com.java2s; import android.content.Context; import android.graphics.Point; import android.util.DisplayMetrics; import android.view.WindowManager; public class Main { public static Point getScreenMetrics(Context context) { DisplayMetrics dm = context.getResources().getDisplayMetrics(); int w_screen = dm.widthPixels; int h_screen = dm.heightPixels; return new Point(w_screen, h_screen); } /** * Returns a valid DisplayMetrics object * * @param context valid context * @return DisplayMetrics object */ public static DisplayMetrics getDisplayMetrics(final Context context) { final WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); final DisplayMetrics metrics = new DisplayMetrics(); windowManager.getDefaultDisplay().getMetrics(metrics); return metrics; } }