Reputation: 467
Does anyone know how to adjust the screen brightness programmatically in Mono for Android.
Upvotes: 0
Views: 1168
Reputation: 4210
This is a really old post, but since It's not answered and I just came across same problem, what I did was the next:
WindowManagerLayoutParams windowManagerLayoutParams = new WindowManagerLayoutParams();
windowManagerLayoutParams.CopyFrom(Window.Attributes);
windowManagerLayoutParams.ScreenBrightness = 1f; //set screen to full brightness
Window.Attributes = windowManagerLayoutParams;
To set it back to auto:
WindowManagerLayoutParams windowManagerLayoutParams = new WindowManagerLayoutParams();
windowManagerLayoutParams.CopyFrom(Window.Attributes);
windowManagerLayoutParams.ScreenBrightness = -1;
Window.Attributes = windowManagerLayoutParams;
In case you want to save the old brightness and set it back to what it was, you can just store it in a variable and use it again.
Upvotes: 1