Code example for Window

Methods: getAttributes, setAttributes

0
    protected void onResume() { 
        Log.d(TAG, "onResume..., restore brightness to " + mBrightness);
        Settings.System.putInt(mContentResolver, Settings.System.SCREEN_BRIGHTNESS, mBrightness);
        //preview brightness changes at this window 
        //get the current window attributes 
        LayoutParams layoutpars = mWindow.getAttributes();
        //set the brightness of this window 
        layoutpars.screenBrightness = mBrightness / (float)255;
        //apply attribute changes to this window 
        mWindow.setAttributes(layoutpars);        
        super.onResume(); 
    } 
 
    @Override 
    protected void onPause() { 
        Log.d(TAG, "onPause..., restore brightness to " + mPreBrightness);
        Settings.System.putInt(mContentResolver, Settings.System.SCREEN_BRIGHTNESS, mPreBrightness);
        //preview brightness changes at this window 
        //get the current window attributes 
        LayoutParams layoutpars = mWindow.getAttributes();
        //set the brightness of this window