Android examples for Phone:Screen
get Current Screen Width Inches
//package com.java2s; import android.content.Context; import android.util.DisplayMetrics; import android.view.Display; import android.view.WindowManager; public class Main { public static double getCurrentScreenWidthInches(Context context) { DisplayMetrics dm = getDisplayMetrics(context); return dm.widthPixels / dm.xdpi; }/*w ww . ja v a 2 s. co m*/ private static DisplayMetrics getDisplayMetrics(Context context) { DisplayMetrics dm = new DisplayMetrics(); getDefaultDisplay(context).getMetrics(dm); return dm; } private static Display getDefaultDisplay(Context context) { WindowManager wm = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); return wm.getDefaultDisplay(); } }