Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 * (c) Winterwell Associates Ltd, used under MIT License. This file is background IP.
 */

import android.content.Context;

import android.graphics.Point;

import android.util.Log;
import android.view.Display;

import android.view.WindowManager;

public class Main {
    public static Point getScreenResolution(Context context) {
        WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Display display = manager.getDefaultDisplay();
        Point wh = new Point(display.getWidth(), display.getHeight());
        if (wh.x == 0 || wh.y == 0) {
            Log.e("AndroidUtils", "Screen resolution " + wh + " for " + context);
        }
        return wh;
    }
}