get Display Height in Dpi - Android android.app

Android examples for android.app:Display

Description

get Display Height in Dpi

Demo Code

import android.content.Context;
import android.util.DisplayMetrics;

public class Main {

  public static float getHeightDpi( Context context) {

    if (null == context) {
      return 0;/*www  .j  ava 2  s . co  m*/
    }
    DisplayMetrics dm = new DisplayMetrics();
    dm = context.getApplicationContext().getResources().getDisplayMetrics();
    return dm.ydpi;
  }

}

Related Tutorials