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 getScreenHeight(Context context) {
    Display defaultDisplay = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE))
            .getDefaultDisplay();/*w w  w .  j av a2  s.c  o m*/
    Point point = new Point();
    defaultDisplay.getSize(point);
    return point.y;
}

From source file:Main.java

public static Integer getDisplayWidth(Context context) {
    DisplayMetrics displayMetrics = new DisplayMetrics();
    WindowManager windowmanager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    windowmanager.getDefaultDisplay().getMetrics(displayMetrics);
    return displayMetrics.widthPixels;
}

From source file:Main.java

public static String getScreenWxH(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);/*ww  w . j a v  a 2 s.  co  m*/
    int width = size.x;
    int height = size.y;

    return width + "x" + height;
}

From source file:Main.java

public static Point getDisplaySize(Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);/*from   ww w .  j  ava  2  s .  c  o m*/
    return point;
}

From source file:Main.java

public static int getScreenWidth(Context context) {
    DisplayMetrics dm = new DisplayMetrics();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    display.getMetrics(dm);//w ww  .  j  a v  a2 s .c  o  m

    return dm.widthPixels;
}

From source file:Main.java

public static Point getScreenSize(Context appContext) {
    final Display display = ((WindowManager) appContext.getSystemService(Context.WINDOW_SERVICE))
            .getDefaultDisplay();/*  ww w  .  java2  s  .c om*/
    final Point point = new Point();
    display.getSize(point);
    return point;
}

From source file:Main.java

public static int getScreenHeight(Context context) {
    DisplayMetrics dm = new DisplayMetrics();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    display.getMetrics(dm);// w  w  w.  ja  va 2 s  .  c  o  m

    return dm.heightPixels;
}

From source file:Main.java

public static DisplayMetrics getDisplayMetrics(Context ctx) {
    DisplayMetrics dm = new DisplayMetrics();
    ((WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(dm);
    return dm;/*ww  w. j  a  va2  s . c o m*/
}

From source file:Main.java

public static int[] getWindowSize(Context context) {
    final WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    final Display display = wm.getDefaultDisplay();
    if (android.os.Build.VERSION.SDK_INT >= 13) {
        Point point = new Point();
        display.getSize(point);//  w ww. ja v a 2s  .co  m
        return new int[] { point.x, point.y };
    } else {
        return new int[] { display.getWidth(), display.getHeight() };
    }
}

From source file:Main.java

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