Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.app.Activity;

import android.graphics.Point;
import android.os.Build;

import android.view.Display;

import android.view.WindowManager;

public class Main {
    @SuppressWarnings("deprecation")
    public static int getScreenHeight(Activity activity) {
        int Measuredheight = 0;
        Point size = new Point();
        WindowManager wm = activity.getWindowManager();

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            wm.getDefaultDisplay().getSize(size);
            Measuredheight = size.y;
        } else {
            Display d = wm.getDefaultDisplay();
            Measuredheight = d.getWidth();
        }

        return Measuredheight;
    }
}