Android examples for Graphics:Pixel
get Dpi Height
//package com.java2s; import java.lang.reflect.Method; import android.content.Context; import android.util.DisplayMetrics; import android.view.Display; import android.view.WindowManager; public class Main { public static int getDpiHeight(Context context) { int dpi = 0; WindowManager manager = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); DisplayMetrics dm = new DisplayMetrics(); @SuppressWarnings("rawtypes") Class c;/* www.java 2 s. c om*/ try { c = Class.forName("android.view.Display"); @SuppressWarnings("unchecked") Method method = c.getMethod("getRealMetrics", DisplayMetrics.class); method.invoke(display, dm); dpi = dm.heightPixels; } catch (Exception e) { e.printStackTrace(); } return dpi; } }