增加活动的屏幕亮度
显然,Android 操作系统中至少有三种不同的技术可以改变屏幕亮度。其中两个在纸杯蛋糕之后不再起作用,而第三个被接受的技术显然有一个错误。
我想在单视图活动开始时增加屏幕亮度,然后在活动结束时将亮度恢复为用户设置。没有按钮,没有第二个视图或第二个活动。只是在开始时达到最大亮度,并在活动结束时返回到原始亮度设置。
我找到的使用 WindowManager.LayoutParams 的当前技术的示例范围从 2 行代码
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 100 / 100.0f;
getWindow().setAttributes(lp);
到几页源代码和大量活动。
是否有一个在开始时最大化屏幕亮度的简单示例,有人可以提供链接?
There are apparently at least three different techniques for changing screen brightness in the Android OS. Two of them no longer work post-cupcake and the third accepted technique evidently has a bug.
I would like to increase screen brightness at the start of a one-view activity then turn the brightness back to the user setting at the end of the activity. No buttons, no second view or second activity. Just a maxed brightness at start and a return to original brightness setting at the end of the activity.
The examples of the current technique using WindowManager.LayoutParams that I have located range from 2 lines of code
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 100 / 100.0f;
getWindow().setAttributes(lp);
to several pages of source code and numerous activities.
Is there a simple example of maxing the screen brightness at start that someone can provide a link to?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以做的简单的事情是使用拖放在 xml 中创建一个 SeekBar 或
在 mainActivity 类中编写其 xml 执行以下操作:
然后编写一个简单的函数:
还要在调用 screenBrightness 函数之前检查亮度模式,因为有时会选择自动模式亮度,在这种情况下亮度不会改变。您还需要清单文件中的权限。
在 onCreate 中 setOnSeekBarChangeListener 之前调用以下函数
Its simple what you can do is make a SeekBar in xml using drag drop or write its xml
in mainActivity class do this:
and then write a simple function :
Also do check the brightness mode before calling screenBrightness function because sometime the mode is selected to auto brightness and in that case the brightness won't change. You also need permission in manifest file too.
Call the function bellow in onCreate before setOnSeekBarChangeListener