Java tutorial
//package com.java2s; import android.app.Activity; import android.graphics.Point; import android.util.Log; public class Main { private static final String TAG = "ScreenUtils"; private static float mScreenWidth = 0, mScreenHeight = 0; public static float getScreenWidth(Activity activity) { if (mScreenWidth == 0) { Point size = new Point(); activity.getWindowManager().getDefaultDisplay().getSize(size); mScreenWidth = size.x; Log.d(TAG, "screen size is " + size); } return mScreenWidth; } }