Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.app.Activity;
import android.graphics.Point;

import android.view.Display;

public class Main {
    /**
     * Method that get the Screen Size
     * @param activity Actual Activity
     * @return array type int 
     */
    public static int[] getScreenSize(Activity activity) {

        //Obtain default display
        Display display = activity.getWindowManager().getDefaultDisplay();
        Point size = new Point();

        //Set Size in case of ICS
        if (android.os.Build.VERSION.SDK_INT >= 13) {
            display.getSize(size);
            return new int[] { size.x, size.y };
        } else {
            return new int[] { display.getWidth(), display.getHeight() };
        }
    }
}