Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.util.DisplayMetrics; public class Main { public static int getScreenWidth(Context context) { if (null == context) { return 0; } DisplayMetrics dm = new DisplayMetrics(); dm = context.getApplicationContext().getResources().getDisplayMetrics(); return dm.widthPixels; } }