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 getScreenResolution(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics outMetrics = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(outMetrics);
    int width = outMetrics.widthPixels;
    int height = outMetrics.heightPixels;
    return width * height;
}

From source file:Main.java

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

From source file:Main.java

public static DisplayMetrics getScreenMetrics(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics dm = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(dm);
    return dm;/* w w  w. j a  v a 2 s  .c o m*/
}

From source file:Main.java

public static int getScreenHeight(Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics dm = new DisplayMetrics();
    windowManager.getDefaultDisplay().getMetrics(dm);
    return dm.heightPixels;
}

From source file:Main.java

public static DisplayMetrics dueDisplayMetrics(Context context) {
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics dm = new DisplayMetrics();
    manager.getDefaultDisplay().getMetrics(dm);
    return dm;/*from   ww w  .ja va 2 s . com*/
}

From source file:Main.java

public static DisplayMetrics getScreenMetrics(Context context) {
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics outMetrics = new DisplayMetrics();
    manager.getDefaultDisplay().getMetrics(outMetrics);
    return outMetrics;
}

From source file:Main.java

public static String getDisplayMetrics(Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

    DisplayMetrics metrics = new DisplayMetrics();
    windowManager.getDefaultDisplay().getMetrics(metrics);

    return String.format("%dx%d", metrics.widthPixels, metrics.heightPixels);
}

From source file:Main.java

public static DisplayMetrics getDisplayMetrices(Context context) {
    WindowManager windowManger = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics outMetrics = new DisplayMetrics();
    windowManger.getDefaultDisplay().getMetrics(outMetrics);
    return outMetrics;
}

From source file:Main.java

public static void closeProgress(Context context, ProgressBar pBar) {
    WindowManager winManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    winManager.removeView(pBar);/*from  w w  w .j  av a2  s.co m*/
}

From source file:Main.java

public static Point getScreenSize(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);//from  w w  w  .j a  v a2s. com
    return size;
}