Set Android screen brightness

I am trying to set the screen brightness in android completely dark. The first time it works fine, but after brightness 0, but I see the screen. How to make android screen completely dark?

This is my code:

WindowManager.LayoutParams params = getWindow().getAttributes(); params.flags |= LayoutParams.FLAG_KEEP_SCREEN_ON; params.screenBrightness = 0.0f; getWindow().setAttributes(params); 
+4
source share
2 answers

All screens have a minimum brightness without completely turning off. This is the setting of 0.0f . This is a hardware limitation and depends on the phone; There is no way to set the screen completely dark using hardware. (You can remove the highlight, as @trumpetlicks answer indicates.)

If you are only trying to control the brightness for a single application, you can use AbsoluteLayout to place your application and place the View with 100% width, 100% height superimposed on top of everything else, and set the background to rgba(0, 0, 0, <your alpha value>) . I think this is as close to dimming as you can get.

+4
source

If I understand your question correctly, you already have one. What you see is an artifact of almost all LCD screens. They have a backlight. Since you have params.flags |= LayoutParams.FLAG_KEEP_SCREEN_ON; , the screen (and its backlight) will certainly continue, the actual pixel values ​​will be black. This sad feature of LCD monitors is that their blacks are only black!

+1
source

All Articles