Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.res.Resources;
import android.util.DisplayMetrics;

public class Main {
    /**
     * Return true if the smallest width in DP of the device is equal or greater than the given
     * value.
     */
    public static boolean isScreenSw(int smallestWidthDp) {
        DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
        float widthDp = displayMetrics.widthPixels / displayMetrics.density;
        float heightDp = displayMetrics.heightPixels / displayMetrics.density;
        float screenSw = Math.min(widthDp, heightDp);
        return screenSw >= smallestWidthDp;
    }
}