Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;

import android.view.Display;
import android.view.WindowManager;

public class Main {

    @SuppressWarnings("deprecation")
    public static String getDisplayMetrics(Context ctx) {
        String metrics = "";
        try {
            Display display = ((WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
            int width = display.getWidth();
            int height = display.getHeight();
            metrics += width;
            metrics += "x";
            metrics += height;
        } catch (Exception e) {
        }

        return metrics;
    }
}