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(Activity context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    int height = wm.getDefaultDisplay().getHeight();
    return height;

}

From source file:Main.java

public static String getResolution(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    if (wm == null)
        return null;

    Display display = wm.getDefaultDisplay();
    if (display == null)
        return null;

    DisplayMetrics metrics = new DisplayMetrics();
    display.getMetrics(metrics);//from www  . j  a v  a  2  s. c o  m
    return metrics.widthPixels + "x" + metrics.heightPixels;
}

From source file:Main.java

public static int getScreenWidth(Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    DisplayMetrics metrics = new DisplayMetrics();
    display.getMetrics(metrics);/*from  ww  w.j  a va  2  s. co m*/
    return metrics.widthPixels;
}

From source file:Main.java

public static int getHeightWindowWithContext(Context mContext) {
    WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);/*from www.  jav  a  2 s .c  om*/
    return size.y;
}

From source file:Main.java

public static DisplayMetrics getScreenSizeInPx(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    DisplayMetrics metrics = new DisplayMetrics();
    display.getMetrics(metrics);/*from  w w  w. ja  va2  s.c o  m*/
    return metrics;
}

From source file:Main.java

public static String getScreenSize(Context context) {
    DisplayMetrics dm = new DisplayMetrics();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(dm);
    return dm.widthPixels + "x" + dm.heightPixels;
}

From source file:Main.java

public static float getScreenDensity(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics outMetrics = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(outMetrics);
    return outMetrics.density;
}

From source file:Main.java

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

From source file:Main.java

public static int getScreenDensityDpi(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics outMetrics = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(outMetrics);
    return outMetrics.densityDpi;
}

From source file:Main.java

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