List of usage examples for android.app Activity getWindow
public Window getWindow()
From source file:Main.java
public static void keepScreenOnOff(Activity activity, boolean isOn) { if (isOn) {/*from www. j a va 2s . co m*/ activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } else { activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } }
From source file:Main.java
public static int $titleBarHeight(Activity activity) { int contentTop = activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop(); int titleBarHeight = contentTop - getStatusHeight(activity); return titleBarHeight; }
From source file:Main.java
public static Bitmap snapShotWithStatusBar(Activity activity) { View view = activity.getWindow().getDecorView(); view.setDrawingCacheEnabled(true);/* w w w .j ava 2 s . c om*/ view.buildDrawingCache(); Bitmap bmp = view.getDrawingCache(); int width = getScreenWidth(activity); int height = getScreenHeight(activity); Bitmap bp = Bitmap.createBitmap(bmp, 0, 0, width, height); view.setDrawingCacheEnabled(false); view.destroyDrawingCache(); return bp; }
From source file:Main.java
/** * Take screenshot without status bar.// w ww .j a v a2s . com * * @param activity * @return screenshot bitmap. */ public static Bitmap takeScreenshot(Activity activity) { View view = activity.getWindow().getDecorView(); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap bitmap = view.getDrawingCache(); Rect rect = new Rect(); activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect); int statusBarHeight = rect.top; int width = activity.getWindowManager().getDefaultDisplay().getWidth(); int height = activity.getWindowManager().getDefaultDisplay().getHeight(); Bitmap bitmap2 = Bitmap.createBitmap(bitmap, 0, statusBarHeight, width, height - statusBarHeight); view.destroyDrawingCache(); return bitmap2; }
From source file:Main.java
public static void hideSoftKeyBoard(Activity activity) { final View v = activity.getWindow().peekDecorView(); if (v != null && v.getWindowToken() != null) { try {/* w w w.j a v a2s. co m*/ ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } catch (Exception e) { e.printStackTrace(); } } }
From source file:Main.java
public static void hideNavbar(Activity act) { if (Build.VERSION.SDK_INT >= 14) { act.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); }//from w w w . ja v a2 s . c om }
From source file:Main.java
public static int getStatusBarHeight(Activity activity) { Rect frame = new Rect(); activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); return frame.top; }
From source file:Main.java
public static void toggleFullScreen(Activity activity, boolean isFull) { Window window = activity.getWindow(); WindowManager.LayoutParams winParams = window.getAttributes(); final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN; if (isFull) { winParams.flags |= bits;/*from ww w .j a v a2s.c om*/ } else { winParams.flags &= ~bits; } window.setAttributes(winParams); }
From source file:Main.java
public static void setBackgroundAlpha(Activity activity, float bgAlpha) { WindowManager.LayoutParams lp = activity.getWindow().getAttributes(); lp.alpha = bgAlpha;//from ww w . ja va 2 s . co m activity.getWindow().setAttributes(lp); }
From source file:Main.java
@SuppressLint("NewApi") public static void setStatusBarColor(Activity activity, int color) { if (isAboveL()) { activity.getWindow().setStatusBarColor(color); }/*from w w w.j a v a2s. co m*/ }