如何从JetPack组成的应用程序中控制设备屏幕的亮度?
我正在制作一个简单的应用程序,我希望,当我按下按钮时,设备的亮度将设置为最大值,当我再次按下时,它会回到以前的状态。但是我在互联网上找不到任何方法,我一直在尝试几种方法,但我无法正常工作。
I am making a simple app in which I want that when I press a button the brightness of the device is set to maximum and when I press it again it goes back to how it was before. but I can't find anywhere on the internet how to do this, I've been trying several ways and I can't get it to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是如何更改亮度的方法,
从本文中获取代码: https://medium.com/@yhdista/change-the--brightness-foror-the-the-screen-thinking-in-compose-84378dce3b6c
Here is how to change brightness
The code is taken from this article: https://medium.com/@yhdista/change-the-brightness-for-the-screen-thinking-in-compose-84378dce3b6c
扩展@mikhail答案。如果使用片段,您可能需要对活动上下文进行一些挖掘
Extending @Mikhail answer. You may have to dig a little bit for activity context, if using fragments