Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;

import android.content.res.Resources;

import android.util.DisplayMetrics;

public class Main {
    private static int getResourceDisplayDensityDPI(Context context) {
        try {
            Resources resources = context.getResources();
            DisplayMetrics displayMetrics = resources.getDisplayMetrics();
            return displayMetrics.densityDpi;
        } catch (NullPointerException expected) {
            return DisplayMetrics.DENSITY_DEFAULT;
        }
    }
}