Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;
import android.content.res.Configuration;

import android.view.WindowManager;

public class Main {
    /**
     * Method getDeviceScreenWidth(), It's used for checking the screen's with
     * and To develop the functionality of horizontal direction or vertical
     * direction, we can used this for seperating the raised issues
     * 
     * @return Integer Type.
     */
    public static int getDeviceScreenWidth(Context context) {
        int width;
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            width = wm.getDefaultDisplay().getHeight();
        } else {
            width = wm.getDefaultDisplay().getWidth();
        }
        return width;
    }
}