Java tutorial
//package com.java2s; //License from project: Open Source License import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Point; import android.view.Display; import android.view.WindowManager; public class Main { @SuppressLint("NewApi") @SuppressWarnings("deprecation") public static int[] getScreenWidthHeight(Context context) { int[] widthAndHeight = new int[2]; WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); if (android.os.Build.VERSION.SDK_INT >= 13) { Point size = new Point(); display.getSize(size); widthAndHeight[0] = size.x; widthAndHeight[1] = size.y; } else { widthAndHeight[0] = display.getWidth(); widthAndHeight[1] = display.getHeight(); } return widthAndHeight; } }