Android Utililty Methods Screen Size Get

List of utility methods to do Screen Size Get

Description

The list of methods to do Screen Size Get are organized into topic(s).

Method

intgetScreenWidth(Context context)
get Screen Width
WindowManager wm = (WindowManager) context
        .getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics dm = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(dm);
return dm.widthPixels;
int[]getScreenSize(Activity act)
get Screen Size
Display display = act.getWindowManager().getDefaultDisplay();
Point size = new Point();
int[] dimensions = new int[2];
display.getSize(size);
dimensions[0] = size.x;
dimensions[1] = size.y;
return dimensions;
intgetDeviceDesity(Activity activity)
get Device Desity
DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
return dm.densityDpi;
int[]getDeviceResolution(Activity activity)
get Device Resolution
int[] args = new int[2];
DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
args[0] = dm.widthPixels;
args[1] = dm.heightPixels;
return args;