Code example for Window

Methods: getAttributes, setAttributes

1
    @Override 
	protected void onCreate(final Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
 
		final Window win = getWindow();
		final WindowManager.LayoutParams winParams = win.getAttributes();
		winParams.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
				| WindowManager.LayoutParams.FLAG_FULLSCREEN;
 
		// set screen brightness to the lowest possible without turning screen 
		// off 
		winParams.screenBrightness = 0.01f;
 
		// NOTE: this doesn't work on some devices (Motorola Droid, X, 2.. etc) 
		if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
			// hack for pre-froyo to set buttonBrightness off 
			try { 
				final Field buttonBrightness = winParams.getClass().getField("buttonBrightness");
				buttonBrightness.set(winParams, WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF);
			} catch (final Exception e) {
				this.trackEvent("buttonBrightnessFail", 1);
			} 
		} else { 
			winParams.buttonBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF;
		} 
 
		win.setAttributes(winParams);
 
		getSupportActionBar().hide(); 
 
		final LinearLayout blackness = new LinearLayout(this);
		blackness.setLayoutParams(new LayoutParams(