Changing screen brightness on a HTC Sense device

家住魔仙堡 提交于 2019-12-01 03:32:46

问题


The old approach

  Window window = getWindow();
  LayoutParams layoutParams = window.getAttributes();
  layoutParams.screenBrightness = newFloatValue;
  window.setAttributes(layoutParams);

doesn't work on HTC Desire with Automatic brightness checked in Settings > Display > Brightness.
Is there a HTC-specific workaround for that?


回答1:


Of course you don't see any changes since the settings are set to Automatic Brightness. That means, any manual changes are disregarded. Or am I missing something?

I've just tested it on a HTC Desire HD (2.3.5) and the screen brightness DOES change for about a second, but then it's immediately re-adjusted/overwritten by the automatic brightness. However, if you uncheck Auto Brightness option in the settings, you can see that the value has changed correctly.

So, imo everything is working as expected. If you want your changes to take effect you might have to disable Auto Brightness first:

Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL); 


来源:https://stackoverflow.com/questions/4611287/changing-screen-brightness-on-a-htc-sense-device

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!