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;

public class Main {
    public static int[] getScreenDP(Context context) {
        int[] screenSize = new int[2];
        DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
        screenSize[0] = Math.round(displayMetrics.widthPixels / displayMetrics.density);
        screenSize[1] = Math.round(displayMetrics.heightPixels / displayMetrics.density);
        return screenSize;
    }
}