Anyone who knows why this code ain't lowering the backlight of my application?
Context context = this;
Settings.System.putInt(context.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS, 255);
Applications are no longer allowed to modify the global brightness. Don't use the tricks people have tried to come up with at various points, these use private APIs and will break in various ways across different devices (and are considered security holes that have been closed on more recent versions of the platform).
The official API to set the brightness is with WindowManager.LayoutParams.screenBrightness, which lets you set the brightness for your own app's window. The platform will automatically take care of changing the brightness as the user moves in and out of your app.
Use this to change it:
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = <some value between 0 and 1>;
getWindow().setAttributes(lp);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With