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.util.DisplayMetrics;

import java.util.HashMap;

public class Main {

    public static HashMap<String, String> getDensity(Context cxt) {
        DisplayMetrics displayMetrics = cxt.getResources().getDisplayMetrics();
        StringBuilder builder = new StringBuilder();
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("Density", displayMetrics.density + "");
        map.put("densityDpi", displayMetrics.densityDpi + "");
        map.put("heightPixels", displayMetrics.heightPixels + "");
        map.put("widthPixels", displayMetrics.widthPixels + "");
        return map;
    }
}