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.util.DisplayMetrics;

public class Main {
    private static int screenW;
    private static int screenH;

    public static int getScreenW(Activity mActivity) {
        if (screenW == 0) {
            initScreen(mActivity);
        }
        return screenW;
    }

    private static void initScreen(Activity mActivity) {
        DisplayMetrics metric = new DisplayMetrics();
        mActivity.getWindowManager().getDefaultDisplay().getMetrics(metric);
        screenW = metric.widthPixels;
        screenH = metric.heightPixels;
    }
}