Example usage for android.content Context WINDOW_SERVICE

List of usage examples for android.content Context WINDOW_SERVICE

Introduction

In this page you can find the example usage for android.content Context WINDOW_SERVICE.

Prototype

String WINDOW_SERVICE

To view the source code for android.content Context WINDOW_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.WindowManager for accessing the system's window manager.

Usage

From source file:Main.java

public static int getScreeWH(Context context) {

    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    DisplayMetrics outMetrics = new DisplayMetrics();
    display.getMetrics(outMetrics);/*from w w  w .j  ava2  s. c o m*/
    return outMetrics.heightPixels;

}

From source file:Main.java

public static int getWidth(Context context) {
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics outMetrics = new DisplayMetrics();
    manager.getDefaultDisplay().getMetrics(outMetrics);

    return outMetrics.widthPixels;
}

From source file:Main.java

public static int getHeight(Context context) {
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics outMetrics = new DisplayMetrics();
    manager.getDefaultDisplay().getMetrics(outMetrics);

    return outMetrics.heightPixels;
}

From source file:Main.java

public static int getScreenWidth(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics displayMetrics = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(displayMetrics);
    return displayMetrics.widthPixels;
}

From source file:Main.java

public static Display getScreenDisplay(Context context) {
    WindowManager wm;/*from   w ww . j ava2  s . c o  m*/
    try {
        wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        return wm.getDefaultDisplay();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static Point getScreenResolution(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point screenResolution = new Point();
    if (android.os.Build.VERSION.SDK_INT >= 13) {
        display.getSize(screenResolution);
    } else {//w w w. j a va  2  s  .  c o  m
        screenResolution.set(display.getWidth(), display.getHeight());
    }

    return screenResolution;
}

From source file:Main.java

public static Point getScreenResolution(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point screenResolution = new Point();
    if (android.os.Build.VERSION.SDK_INT >= 13) {
        display.getSize(screenResolution);
    } else {//from ww  w.  ja va2  s . c  om
        screenResolution.set(display.getWidth(), display.getHeight());
    }
    return screenResolution;
}

From source file:Main.java

public static int getScreenWidth(Activity context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    int width = wm.getDefaultDisplay().getWidth();
    return width;
}

From source file:Main.java

public static DisplayMetrics getDeviceDisplayMetrics(Context context) {
    android.view.WindowManager windowsManager = (android.view.WindowManager) context
            .getSystemService(Context.WINDOW_SERVICE);
    android.view.Display display = windowsManager.getDefaultDisplay();
    DisplayMetrics outMetrics = new DisplayMetrics();
    display.getMetrics(outMetrics);//from   w w  w  . jav  a 2 s .c  om

    return outMetrics;
}

From source file:Main.java

public static int getScreenWidth(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics metrics = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(metrics);
    return metrics.widthPixels;
}