[英]How to changed system brightness to the maximum programatically in android
I want to change system brightness to the maximum when an activity is launched.我想在启动活动时将系统亮度更改为最大。 I use following examples but they didn't work properly .
我使用以下示例,但它们无法正常工作。
Also the system brightness shouldn't change when an application is running.此外,应用程序运行时系统亮度不应改变。
Change the System Brightness Programmatically 以编程方式更改系统亮度
changing screen brightness programmatically in android 在android中以编程方式更改屏幕亮度
How could I achive this process .我怎么能达到这个过程。 Any ideas about this ?
有什么想法吗?
Thank you.谢谢你。
You can use this :你可以使用这个:
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = (float)WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL;
getWindow().setAttributes(lp);
You should note that this method doesn't change system settings, and the brightness will be back to normal once the activity is paused or destroyed,需要注意的是,这个方法不会改变系统设置,一旦activity暂停或者销毁,亮度就会恢复正常,
Honestly, I don't remember how to change system settings' brightness, but once I find it out,I will post another answer.老实说,我不记得如何更改系统设置的亮度,但是一旦我找到它,我会发布另一个答案。
If you want to change brightness back to normal then replace BRIGHTNESS_OVERRIDE_FULL
with BRIGHTNESS_OVERRIDE_NONE
.如果您想将亮度恢复正常,请将
BRIGHTNESS_OVERRIDE_FULL
替换为BRIGHTNESS_OVERRIDE_NONE
。
Hope this helps :D希望这会有所帮助:D
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.