get Screen Density Dpi - Android User Interface

Android examples for User Interface:Screen Resolution

Description

get Screen Density Dpi

Demo Code


//package com.java2s;

import android.content.Context;

import android.util.DisplayMetrics;

public class Main {
    public static int getScreenDensityDpi(Context context) {
        DisplayMetrics metrics = context.getApplicationContext()
                .getResources().getDisplayMetrics();
        return (int) (metrics.density * 160);
    }/*from w  w w  .  j  a  v  a 2s  .c o  m*/
}

Related Tutorials