List of usage examples for android.app Activity getWindow
public Window getWindow()
From source file:Main.java
public static void hideSoftInputView(Activity activity) { if (activity.getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { InputMethodManager manager = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); View currentFocus = activity.getCurrentFocus(); if (currentFocus != null) { manager.hideSoftInputFromWindow(currentFocus.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }/*from w w w . j a va 2 s . co m*/ } }
From source file:Main.java
public static View getActionBarView(Activity activity) { Window window = activity.getWindow(); View v = window.getDecorView(); // int resId = activity.getResources().getIdentifier("action_bar_container", "id", "android"); int resId = activity.getResources().getIdentifier("action_bar_container", "id", activity.getPackageName()); return v.findViewById(resId); }
From source file:Main.java
public static void resumeSystemUi(Activity activity) { View decorView = activity.getWindow().getDecorView(); // Calling setSystemUiVisibility() with a value of 0 clears // all flags. decorView.setSystemUiVisibility(0);//w w w.ja v a 2s . c om }
From source file:Main.java
public static void showNavBar(Activity activity) { View decorView = activity.getWindow().getDecorView(); int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; decorView.setSystemUiVisibility(uiOptions); activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_FULLSCREEN); }
From source file:Main.java
@TargetApi(VERSION_CODES.KITKAT) public static void showSystemUI(Activity activity) { View decorView = activity.getWindow().getDecorView(); decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); }
From source file:Main.java
/** * Show the activity over the lockscreen and wake up the device. If you * launched the app manually both of these conditions are already true. If * you deployed from the IDE, however, this will save you from hundreds of * power button presses and pattern swiping per day! *//*from w w w . j a v a 2s . c om*/ public static void riseAndShine(Activity activity) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); PowerManager power = (PowerManager) activity.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock lock = power.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "wakeup!"); lock.acquire(); lock.release(); }
From source file:Main.java
/** * <prev>/*w w w.j ava 2s. c o m*/ * Get root view of an activity. * </prev> */ public static View getRootView(Activity activity) { return activity.getWindow().getDecorView().findViewById(android.R.id.content); }
From source file:Main.java
public static void hideInput(Activity activity) { View view = activity.getWindow().peekDecorView(); if (view != null) { InputMethodManager inputmanger = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0); }/*from ww w . j av a2 s . co m*/ }
From source file:Main.java
public static void hideNavBar(Activity activity) { View decorView = activity.getWindow().getDecorView(); int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; decorView.setSystemUiVisibility(uiOptions); activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_FULLSCREEN); }
From source file:Main.java
public static void setTranslucentStatus(Activity activity, boolean on) { Window win = activity.getWindow(); WindowManager.LayoutParams winParams = win.getAttributes(); win.setAttributes(winParams);/*from w w w . j a va2 s . com*/ }