Example usage for android.app Activity getWindow

List of usage examples for android.app Activity getWindow

Introduction

In this page you can find the example usage for android.app Activity getWindow.

Prototype

public Window getWindow() 

Source Link

Document

Retrieve the current android.view.Window for the activity.

Usage

From source file:Main.java

public static View getContentViewFrom(Activity activity) {
    return activity.getWindow().getDecorView();
}

From source file:Main.java

public static Bitmap getScreenshotsForCurrentWindow(Activity activity) {
    View cv = activity.getWindow().getDecorView();
    Bitmap bmp = Bitmap.createBitmap(cv.getWidth(), cv.getHeight(), Bitmap.Config.ARGB_4444);
    cv.draw(new Canvas(bmp));
    return bmp;//w w  w .  j  av a  2s .  c o m
}

From source file:Main.java

public static void hideStatusBar(Activity activity) {
    View decorView = activity.getWindow().getDecorView();
    int uiVisibility = decorView.getSystemUiVisibility();
    decorView.setSystemUiVisibility(uiVisibility | View.SYSTEM_UI_FLAG_FULLSCREEN);
}

From source file:Main.java

public static View getRootView(Activity activity) {
    View view1 = activity.getWindow().getDecorView().findViewById(android.R.id.content);
    View view2 = activity.findViewById(android.R.id.content);
    View view3 = activity.findViewById(android.R.id.content).getRootView();

    return view2;
}

From source file:Main.java

public static Bitmap captureScreen(Activity context) {
    View cv = context.getWindow().getDecorView();
    Bitmap bmp = Bitmap.createBitmap(cv.getWidth(), cv.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(bmp);
    cv.draw(canvas);//from  ww w  . j a v a2s  .co m
    return bmp;
}

From source file:Main.java

public static void hideInputMethod(Activity activity) {
    activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}

From source file:Main.java

public static void KeyBoardCancle(Activity act) {

    View view = act.getWindow().peekDecorView();
    if (view != null) {

        InputMethodManager inputmanger = (InputMethodManager) act
                .getSystemService(Activity.INPUT_METHOD_SERVICE);
        inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }//from  ww w  .jav a 2s. co  m
}

From source file:Main.java

public static void forceShowInputMethod(Activity activity) {
    Window window = activity.getWindow();
    window.setSoftInputMode(// w  w w .  j  a v  a2s  .co  m
            window.getAttributes().softInputMode | WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}

From source file:Main.java

public static void requestImmersiveStickyMode(Activity activity) {
    activity.getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}

From source file:Main.java

public static void setFullScreen(Activity activity) {
    Window window = activity.getWindow();
    if (window != null) {
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }//from ww w.ja  va 2 s .  c o  m
}