Java tutorial
//package com.java2s; import android.app.Activity; import android.graphics.Point; import android.os.Build; import android.view.Display; import android.view.WindowManager; public class Main { @SuppressWarnings("deprecation") public static int getScreenWidth(Activity activity) { int Measuredwidth = 0; Point size = new Point(); WindowManager wm = activity.getWindowManager(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { wm.getDefaultDisplay().getSize(size); Measuredwidth = size.x; } else { Display d = wm.getDefaultDisplay(); Measuredwidth = d.getWidth(); } return Measuredwidth; } }