Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.Activity; import android.content.Context; import android.view.WindowManager; public class Main { public static int getScreenWidth(Activity context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); int width = wm.getDefaultDisplay().getWidth(); return width; } }