Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.annotation.SuppressLint;
import android.app.Activity;

import android.os.Build;
import android.util.DisplayMetrics;

public class Main {
    @SuppressLint("NewApi")
    public static float[] getRealWH(Activity activity) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            DisplayMetrics metrics = new DisplayMetrics();
            activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics);

            int height = metrics.heightPixels;
            int width = metrics.widthPixels;
            float[] wh = { width, height };
            return wh;
        }
        float[] aa = { 0, 0 };
        return aa;
    }
}