android 获取和设置屏幕亮度
16lz
2021-01-23
android 获取和设置屏幕亮度
# 获取屏幕亮度
public static int getScreenBrightness(Activity activity) {
int value = 0;
ContentResolver cr = activity.getContentResolver();
try {
value = Settings.System.getInt(cr, Settings.System.SCREEN_BRIGHTNESS);
} catch (SettingNotFoundException e) {
}
return value;
}
# 设置屏幕亮度
public static void setScreenBrightness(Activity activity, int value) {
WindowManager.LayoutParams params = activity.getWindow().getAttributes();
params.screenBrightness = value / 255f;
activity.getWindow().setAttributes(params);
}
更多相关文章
- android 屏幕方向总结
- android获取设备屏幕大小的方法
- android唤醒屏幕/保持屏幕唤醒
- Android屏幕休眠和唤醒
- Android 屏幕截图 代码
- Android触控屏幕Gesture(GestureDetector和SimpleOnGestureListe
- Android保持屏幕常亮的方法总结
- android获取屏幕信息